Browse Source

МОБИЛКА

kamil 5 months ago
parent
commit
a555948600

+ 14 - 0
src/DontHarm.sln

@@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DontHarmImport", "DontHarmI
 EndProject
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DontHarmWebApi", "DontHarmWebApi\DontHarmWebApi.csproj", "{EB31F186-5271-414E-982B-2BA76F824339}"
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DontHarmWebApi", "DontHarmWebApi\DontHarmWebApi.csproj", "{EB31F186-5271-414E-982B-2BA76F824339}"
 EndProject
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DontHarmMobile.Android", "DontHarmMobile\DontHarmMobile.Android\DontHarmMobile.Android.csproj", "{31AC8B3C-A2EC-4BC7-91FA-F81102E816B7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DontHarmMobile", "DontHarmMobile\DontHarmMobile\DontHarmMobile.csproj", "{D052C6E9-C295-46C0-9405-5CEFCC15901E}"
+EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Debug|Any CPU = Debug|Any CPU
@@ -27,6 +31,16 @@ Global
 		{EB31F186-5271-414E-982B-2BA76F824339}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{EB31F186-5271-414E-982B-2BA76F824339}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{EB31F186-5271-414E-982B-2BA76F824339}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{EB31F186-5271-414E-982B-2BA76F824339}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{EB31F186-5271-414E-982B-2BA76F824339}.Release|Any CPU.Build.0 = Release|Any CPU
 		{EB31F186-5271-414E-982B-2BA76F824339}.Release|Any CPU.Build.0 = Release|Any CPU
+		{31AC8B3C-A2EC-4BC7-91FA-F81102E816B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{31AC8B3C-A2EC-4BC7-91FA-F81102E816B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{31AC8B3C-A2EC-4BC7-91FA-F81102E816B7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+		{31AC8B3C-A2EC-4BC7-91FA-F81102E816B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{31AC8B3C-A2EC-4BC7-91FA-F81102E816B7}.Release|Any CPU.Build.0 = Release|Any CPU
+		{31AC8B3C-A2EC-4BC7-91FA-F81102E816B7}.Release|Any CPU.Deploy.0 = Release|Any CPU
+		{D052C6E9-C295-46C0-9405-5CEFCC15901E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{D052C6E9-C295-46C0-9405-5CEFCC15901E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D052C6E9-C295-46C0-9405-5CEFCC15901E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{D052C6E9-C295-46C0-9405-5CEFCC15901E}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE

+ 8 - 1
src/DontHarmMobile/DontHarmMobile.Android/DontHarmMobile.Android.csproj

@@ -3,7 +3,7 @@
   <PropertyGroup>
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{740EF9CC-1A58-4654-B641-13EA7327C400}</ProjectGuid>
+    <ProjectGuid>{31AC8B3C-A2EC-4BC7-91FA-F81102E816B7}</ProjectGuid>
     <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <TemplateGuid>{c9e5eea5-ca05-42a1-839b-61506e0a37df}</TemplateGuid>
     <TemplateGuid>{c9e5eea5-ca05-42a1-839b-61506e0a37df}</TemplateGuid>
     <OutputType>Library</OutputType>
     <OutputType>Library</OutputType>
@@ -38,6 +38,7 @@
     <EnableLLVM>false</EnableLLVM>
     <EnableLLVM>false</EnableLLVM>
     <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
     <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
     <BundleAssemblies>false</BundleAssemblies>
     <BundleAssemblies>false</BundleAssemblies>
+    <MandroidI18n />
   </PropertyGroup>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
     <DebugSymbols>true</DebugSymbols>
@@ -91,5 +92,11 @@
   <ItemGroup>
   <ItemGroup>
     <Folder Include="Resources\drawable\" />
     <Folder Include="Resources\drawable\" />
   </ItemGroup>
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\DontHarmMobile\DontHarmMobile.csproj">
+      <Project>{FD405DE5-A76A-4B80-BD68-AEF906AC329B}</Project>
+      <Name>DontHarmMobile</Name>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
   <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
 </Project>
 </Project>

File diff suppressed because it is too large
+ 10869 - 34
src/DontHarmMobile/DontHarmMobile.Android/Resources/Resource.designer.cs


+ 0 - 1
src/DontHarmMobile/DontHarmMobile/App.xaml.cs

@@ -9,7 +9,6 @@ namespace DontHarmMobile
         public App()
         public App()
         {
         {
             InitializeComponent();
             InitializeComponent();
-
             MainPage = new NavigationPage(new MainPage());
             MainPage = new NavigationPage(new MainPage());
         }
         }
 
 

+ 36 - 0
src/DontHarmMobile/DontHarmMobile/Client.cs

@@ -0,0 +1,36 @@
+using System;
+
+namespace DontHarmMobile
+{
+    public class Client
+    {
+        public int id { get; set; }
+        public int type { get; set; }
+        public string login { get; set; }
+        public string password { get; set; }
+        public string surname { get; set; }
+        public string name { get; set; }
+        public string patronymic { get; set; }
+        public DateTime birthdate { get; set; }
+        public int passportSeries { get; set; }
+        public int passportNumber { get; set; }
+        public string phone { get; set; }
+        public string email { get; set; }
+        public object companyName { get; set; }
+        public object companyAddress { get; set; }
+        public int inn { get; set; }
+        public int account { get; set; }
+        public int bik { get; set; }
+        public bool hidden { get; set; }
+        public object[] invoices { get; set; }
+        public object[] orders { get; set; }
+
+        public string HumanName
+        {
+            get
+            {
+                return surname + " " + name[0] + ". " + patronymic[0] + ".";
+            }
+        }
+    }
+}

+ 7 - 0
src/DontHarmMobile/DontHarmMobile/DontHarmMobile.csproj

@@ -11,7 +11,14 @@
   </PropertyGroup>
   </PropertyGroup>
 
 
   <ItemGroup>
   <ItemGroup>
+    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
     <PackageReference Include="Xamarin.Forms" Version="5.0.0.2196" />
     <PackageReference Include="Xamarin.Forms" Version="5.0.0.2196" />
     <PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
     <PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
   </ItemGroup>
   </ItemGroup>
+
+  <ItemGroup>
+    <EmbeddedResource Update="OrdersPage.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+  </ItemGroup>
 </Project>
 </Project>

+ 4 - 0
src/DontHarmMobile/DontHarmMobile/DontHarmMobile.csproj.user

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup />
+</Project>

+ 20 - 15
src/DontHarmMobile/DontHarmMobile/MainPage.xaml

@@ -4,21 +4,26 @@
              x:Class="DontHarmMobile.MainPage">
              x:Class="DontHarmMobile.MainPage">
 
 
     <StackLayout>
     <StackLayout>
-        <Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
-            <Label Text="Welcome to Xamarin.Forms!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/>
-        </Frame>
-        <Label Text="Start developing now" FontSize="Title" Padding="30,10,30,10"/>
-        <Label Text="Make changes to your XAML file and save to see your UI update in the running app with XAML Hot Reload. Give it a try!" FontSize="16" Padding="30,0,30,0"/>
-        <Label FontSize="16" Padding="30,24,30,0">
-            <Label.FormattedText>
-                <FormattedString>
-                    <FormattedString.Spans>
-                        <Span Text="Learn more at "/>
-                        <Span Text="https://aka.ms/xamarin-quickstart" FontAttributes="Bold"/>
-                    </FormattedString.Spans>
-                </FormattedString>
-            </Label.FormattedText>
-        </Label>
+        <!--Список всех клиентов-->
+        <ListView 
+            x:Name="lvClients"
+            ItemSelected="lvClients_ItemSelected"
+            HasUnevenRows="True">
+            <ListView.ItemTemplate>
+                <DataTemplate>
+                    <ViewCell>
+                        <StackLayout>
+                            <Label
+                                Margin="5"
+                                FontSize="30"
+                                HorizontalOptions="Center"
+                                Text="{Binding HumanName}"/>
+                            <!--Image here-->
+                        </StackLayout>
+                    </ViewCell>
+                </DataTemplate>
+            </ListView.ItemTemplate>
+        </ListView>
     </StackLayout>
     </StackLayout>
 
 
 </ContentPage>
 </ContentPage>

File diff suppressed because it is too large
+ 6 - 0
src/DontHarmMobile/DontHarmMobile/MainPage.xaml.cs


+ 27 - 0
src/DontHarmMobile/DontHarmMobile/Order.cs

@@ -0,0 +1,27 @@
+using System;
+
+namespace DontHarmMobile
+{
+    public class Order
+    {
+        public int id { get; set; }
+        public int clientId { get; set; }
+        public DateTime created_at { get; set; }
+
+        public string OrderName
+        {
+            get
+            {
+                return "Заказ #" + id.ToString();
+            }
+        }
+
+        public string CreatedAtText
+        {
+            get
+            {
+                return "Создан: " + created_at.ToString();
+            }
+        }
+    }
+}

+ 53 - 0
src/DontHarmMobile/DontHarmMobile/OrdersPage.xaml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             x:Class="DontHarmMobile.OrdersPage">
+    <ContentPage.Content>
+        <Grid>
+            <Grid.RowDefinitions>
+                <RowDefinition Height="*"/>
+                <RowDefinition Height="Auto"/>
+            </Grid.RowDefinitions>
+
+            <ListView
+                x:Name="lvOrders"
+                Grid.Row="0"
+                HasUnevenRows="True">
+                <ListView.ItemTemplate>
+                    <DataTemplate>
+                        <ViewCell>
+                            <Grid>
+                                <Grid.RowDefinitions>
+                                    <RowDefinition Height="Auto"/>
+                                    <RowDefinition Height="Auto"/>
+                                </Grid.RowDefinitions>
+
+                                <Label 
+                                    Margin="4"
+                                    FontAttributes="Bold"
+                                    FontSize="16"
+                                    Grid.Row="0"
+                                    HorizontalOptions="Start"
+                                    Text="{Binding OrderName}"/>
+                                <Label 
+                                    Margin="4"
+                                    FontAttributes="Italic"
+                                    FontSize="12"
+                                    Grid.Row="1"
+                                    HorizontalOptions="Start"
+                                    Text="{Binding CreatedAtText}"/>
+                            </Grid>
+                        </ViewCell>
+                    </DataTemplate>
+                </ListView.ItemTemplate>
+            </ListView>
+
+            <Button 
+                Grid.Row="1"
+                x:Name="btnAdd"
+                Clicked="btnAdd_Clicked"
+                Text="Добавить пустой заказ"/>
+
+        </Grid>
+    </ContentPage.Content>
+</ContentPage>

+ 51 - 0
src/DontHarmMobile/DontHarmMobile/OrdersPage.xaml.cs

@@ -0,0 +1,51 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+
+namespace DontHarmMobile
+{
+    [XamlCompilation(XamlCompilationOptions.Compile)]
+    public partial class OrdersPage : ContentPage
+    {
+        public Client CurrentClient { get; set; }
+        public Order CurrentOrder { get; set; }
+        
+        private static readonly string ip = "192.168.229.20";
+        private static readonly string port = "10000";
+
+        public OrdersPage(Client client)
+        {
+            InitializeComponent();
+            CurrentClient = client;
+            
+            CurrentOrder = new Order();
+            CurrentOrder.clientId = client.id;
+
+            BindingContext = this;
+
+            UpdateOrders();
+        }
+
+        private void UpdateOrders()
+        {
+            var client = new WebClient();
+            var response = client.DownloadString($"http://{ip}:{port}/Orders/ListByClientId/{CurrentClient.id}");
+
+            lvOrders.ItemsSource = JsonConvert.DeserializeObject<List<Order>>(response);
+        }
+
+        private void btnAdd_Clicked(object sender, EventArgs e)
+        {
+            var client = new WebClient();
+            client.DownloadString($"http://{ip}:{port}/Orders/Create?ClientId={CurrentClient.id}");
+            UpdateOrders();
+        }
+    }
+}

+ 0 - 1
src/DontHarmWebApi/Controllers/ClientsController.cs

@@ -27,7 +27,6 @@ namespace DontHarmWebApi.Controllers
                 return Problem("Entity set 'user12Context.Clients'  is null.");
                 return Problem("Entity set 'user12Context.Clients'  is null.");
             }
             }
             return Json(await _context.Clients.ToListAsync());
             return Json(await _context.Clients.ToListAsync());
-                          
         }
         }
 
 
         // GET: /Clients/Details/<int>
         // GET: /Clients/Details/<int>

+ 51 - 0
src/DontHarmWebApi/Controllers/OrdersController.cs

@@ -0,0 +1,51 @@
+using DontHarmWebApi.Entities;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+
+namespace DontHarmWebApi.Controllers
+{
+    public class OrdersController : Controller
+    {
+        private readonly user12Context _context;
+        public OrdersController(user12Context context)
+        {
+            _context = context;
+        }
+
+        // GET: /Orders/ListByClientId/<int>
+        // Возвращает все заказы клиента
+        public async Task<IActionResult> ListByClientId(int? id)
+        {
+            if (id == null || _context.Orders == null)
+            {
+                return NotFound();
+            }
+
+            var data = _context.Orders.Where(e => e.ClientId == id);
+            var list = await data.ToListAsync();
+
+            var output = new List<object>();
+            list.ForEach(item =>
+            {
+                output.Add(new 
+                {
+                    id = item.Id,
+                    clientId = item.ClientId,
+                    created_at = item.CreatedAt
+                });
+            });
+
+            return Json(output);
+        }
+
+        // Get: Orders/Create
+        [HttpGet]
+        public async Task<IActionResult> Create([Bind("ClientId")] Order order)
+        {
+            order.CreatedAt = DateTime.Now;
+            _context.Add(order);
+            await _context.SaveChangesAsync();
+            return Json(order);
+        }
+    }
+}

+ 1 - 1
src/DontHarmWebApi/DontHarmWebApi.csproj.user

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
   <PropertyGroup>
-    <Controller_SelectedScaffolderID>MvcControllerWithContextScaffolder</Controller_SelectedScaffolderID>
+    <Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
     <Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
     <Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
     <WebStackScaffolding_ControllerDialogWidth>650</WebStackScaffolding_ControllerDialogWidth>
     <WebStackScaffolding_ControllerDialogWidth>650</WebStackScaffolding_ControllerDialogWidth>
     <WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
     <WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>

Some files were not shown because too many files changed in this diff