public async Task <ActionResult <LocationAPI> > Create(LocationAPI user) { _context.AllLocationsAPI.Add(user); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetById), new { id = user.ID }, user)); }
public async Task <LocationAPI> PerformGetLocationAsync() { Debug.WriteLine("Activate get Location"); var uri = new Uri("https://ipinfo.io/"); try { Debug.WriteLine("link:" + uri); var response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); Debug.WriteLine(content); location = Newtonsoft.Json.JsonConvert.DeserializeObject <LocationAPI>(content); return(location); } } catch (Exception ex) { Debug.WriteLine(@" ERROR {0}", ex.Message); } throw new NotImplementedException(); }
bool InterfaceLocation.AddLocation(Location location) { LocationAPI locationAPI = new LocationAPI(); locationAPI.AddLocation(location); return(true); }
public async Task <IActionResult> Update(long id, LocationAPI user) { if (id != user.ID) { return(BadRequest()); } _context.Entry(user).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public LocationRecipeViewModel(int locationId) { this.locatioId = locationId; locationAPI = new LocationAPI(); var recipes = locationAPI.GetRecipes(locationId).Select(x => new Model.Recipe() { Name = x.Name, Id = x.Id }); Recipes = new ObservableCollection <Model.Recipe>(recipes); }
static void Main(string[] args) { UserSettings gUserSettings = new UserSettings(); LocationAPI gLocationData = new LocationAPI(ref gUserSettings); //Location API (distance) //Distance API //Location Objects //Weather API //Weather Objects //FindBestTimes //PrintBestTimes }
public LocationProductsViewModel(int locationId) { locationApi = new LocationAPI(); var products = locationApi.GetProduct(locationId).Select(x => new ProductStorage() { ProductName = x.Name, Price = x.Price, Value = x.Value, TotalPrice = x.Price * Convert.ToDecimal(x.Value) }); Products = new ObservableCollection <ProductStorage>(products); }
private static void readPrintLocations() { string[] locations = File.ReadAllLines(@"C:\AppFiles\printcoord.txt"); for (int i = 0; i < locations.Length; i++) { PrintLocation loc = new PrintLocation(); string[] temp = locations[i].Split(':'); loc.Name = temp[0]; loc.Latitude = double.Parse(temp[1]); loc.Longitude = double.Parse(temp[2]); LocationAPI.AddPrintLocation(loc); } }
public OrderCreateViewModel(int locationId) { this.locationId = locationId; locationApi = new LocationAPI(); var suppliers = locationApi.GetSupplier(locationId).Select(x => new Supplier() { Id = x.Id, Name = x.Name }); Suppliers = new ObservableCollection <Supplier>(suppliers); SelectCommand = new Command(Select); Products = new ObservableCollection <ProductOrdered>(); SaveCommand = new Command(Save); }
private static void readComputerLocations() { string[] locations = File.ReadAllLines(@"C:\AppFiles\computercoords.txt"); for (int i = 0; i < locations.Length; i++) { ComputerLocation loc = new ComputerLocation(); string[] temp = locations[i].Split(';'); loc.Name = temp[0]; loc.SubTitle = temp[1]; loc.Latitude = double.Parse(temp[2]); loc.Longitude = double.Parse(temp[3]); LocationAPI.AddComputerLocation(loc); } }
public LocationSuppliersViewModel(int locatonId) { this.locationId = locatonId; locationApi = new LocationAPI(); var suppliers = locationApi.GetSupplier(this.locationId).Select(x => new Supplier() { Id = x.Id, Name = x.Name, OpenCommand = new Command((() => { })) }); Suppliers = new ObservableCollection <Supplier>(suppliers); }
public LocationsViewModel() { locationApi = new LocationAPI(); var location = locationApi.GetAll().Select(x => new Model.Location { Id = x.Id, Name = x.Name, Detail = new Command((() => { Detail(x.Id); })) }); Locations = new ObservableCollection <Model.Location>(location); }
public OrderViewModel(int locationId) { locationApi = new LocationAPI(); var orders = locationApi.GetOrders(locationId).Select(x => new Model.Order() { OrderId = x.OrderId, SupplierName = x.SupplierName, OrderDate = x.OrderDate, AcceptDate = x.AcceptDate, Accept = x.Accept }).ToList(); NewOrders = new ObservableCollection <Model.Order>(orders.Where(x => !x.Accept)); AcceptedOrders = new ObservableCollection <Model.Order>(orders.Where(x => x.Accept)); }
public RecipeCreateViewModel() { productApi = new ProductsAPI(); var products = productApi.GetAll().Select(x => new ProductRecipe() { ProductId = x.Id, ProductName = x.Name, Value = 0, AddCommand = new Command((() => { AddProduct(x.Id); })), RemoveCommand = new Command((() => { RemoveProduct(x.Id); })) }); Products = new ObservableCollection <ProductRecipe>(products); ProductsRecipe = new ObservableCollection <ProductRecipe>(); locationApi = new LocationAPI(); var locations = locationApi.GetAll().Select(x => new Model.Location() { Id = x.Id, Name = x.Name, AddCommand = new Command(() => { AddLocation(x.Id); }), RemoveCommand = new Command((() => { RemoveLocation(x.Id); })) }); Locations = new ObservableCollection <Model.Location>(locations); LocationsRecipe = new ObservableCollection <Model.Location>(); SaveCommand = new Command((() => { this.Save(); })); }
public async Task PerformUpdateLocationAsync(LocationAPI location, bool isNewLocation, string itemcode) { Debug.WriteLine("Activate get Location"); var uri = new Uri(string.Format(Constants.RestUpdateLocationUrl, string.Empty)); LocationData LocalData = new LocationData() { code = itemcode, city = location.city, country = location.country, hostname = location.hostname, ip = location.ip, loc = location.loc, org = location.org, region = location.region, device = "app" }; try { var json = JsonConvert.SerializeObject(LocalData); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = null; if (isNewLocation) { Debug.WriteLine("link:" + uri); response = await client.PostAsync(uri, content); } if (response.IsSuccessStatusCode) { Debug.WriteLine(@" Location successfully saved. Status code" + response.StatusCode + "\n" + response.RequestMessage); } } catch (Exception ex) { Debug.WriteLine(@" ERROR {0}", ex.Message); } }
public LocationMenuViewModel(int locationId) { this.locationId = locationId; locationApi = new LocationAPI(); #region Create Menu Menu = new List <LocationItemMenu>(); var productItemMenu = new LocationItemMenu() { NameMenu = "Продукты", Open = new Command((() => { var view = new LocationProductsView(); var viewmodel = new LocationProductsViewModel(this.locationId); view.DataContext = viewmodel; view.ShowDialog(); })) }; var recipeItemMenu = new LocationItemMenu() { NameMenu = "Рецепты", Open = new Command((() => { var view = new LocationRecipesView(); var viewmodel = new LocationRecipeViewModel(locationId); view.DataContext = viewmodel; view.ShowDialog(); })) }; var supplierItemMenu = new LocationItemMenu() { NameMenu = "Поставщики", Open = new Command((() => { var view = new LocationSuppliersView(); var viewmodel = new LocationSuppliersViewModel(this.locationId); view.DataContext = viewmodel; view.ShowDialog(); })) }; var orderItemMenu = new LocationItemMenu() { NameMenu = "Просмотр заказов", Open = new Command((() => { var view = new OrderView(); var viewmodel = new OrderViewModel(this.locationId); view.DataContext = viewmodel; view.ShowDialog(); })) }; var orderCreateItemMenu = new LocationItemMenu() { NameMenu = "Создать заказ", Open = new Command((() => { var view = new OrderCreateView(); var viewmodel = new OrderCreateViewModel(this.locationId); view.DataContext = viewmodel; view.ShowDialog(); })) }; var transferProductItemMenu = new LocationItemMenu() { NameMenu = "Трансфер", Open = new Command() }; var disposalProductItemMenu = new LocationItemMenu() { NameMenu = "Списание продуктов", Open = new Command() }; var salesProductItemMenu = new LocationItemMenu() { NameMenu = "Продажи блюд", Open = new Command() }; Menu.Add(productItemMenu); Menu.Add(recipeItemMenu); Menu.Add(supplierItemMenu); Menu.Add(orderCreateItemMenu); Menu.Add(orderItemMenu); Menu.Add(transferProductItemMenu); Menu.Add(disposalProductItemMenu); Menu.Add(salesProductItemMenu); #endregion }
int InterfaceLocation.GetLocationIdByName(string name) { LocationAPI locationAPI = new LocationAPI(); return(locationAPI.GetIdByName(name)); }
public List <Location> GetLocations() { LocationAPI locationAPI = new LocationAPI(); return(locationAPI.GetLocation()); }
public Location GetLocationById(int id) { LocationAPI locationAPI = new LocationAPI(); return(locationAPI.GetLocationById(id)); }
public async void SetLayout(string itemcode) { Debug.WriteLine("active layout"); NavigationPage.SetHasBackButton(this, true); NavigationPage.SetHasNavigationBar(this, true); string hotline = "19001122"; var scroll = new ScrollView() { BackgroundColor = Color.FromHex("#dddee3") }; var layout = new StackLayout(); var paddingTLR = new Thickness(10, 10, 10, 10); var paddingTB = new Thickness(0, 10, 0, 10); //Trích xuất dữ liệu LayoutDataResult dataresult = new LayoutDataResult(); ProductAPI proapi = new ProductAPI(); CompanyAPI comapi = new CompanyAPI(); ImageAPI image = new ImageAPI(); try { proapi = await App.SvManager.GetProductAsync(itemcode); comapi = await App.SvManager.GetCompanyAsync(itemcode); image = await App.SvManager.GetImageAsync(itemcode); Product pro = proapi.item; Company com = comapi.company; dataresult.product = pro; dataresult.company = com; if (image.image.Contains("data:image/png;base64,")) { string head = "data:image/png;base64,"; image.image = image.image.Remove(0, head.Length); } Debug.WriteLine(dataresult.image); dataresult.image = image.image; StackLayout stack1 = new StackLayout(); Image verifyimage = new Image { HeightRequest = Application.Current.MainPage.Width / 4, WidthRequest = Application.Current.MainPage.Width / 4, }; System.Diagnostics.Debug.WriteLine("Image point" + Application.Current.MainPage.Width / 4); Label verifyLabel = new Label() { TextColor = Color.Red }; Label thanksLabel = new Label() { TextColor = Color.Red }; var muaspButton = new Button { Text = "MUA SẢN PHẨM", TextColor = Color.White, BackgroundColor = Color.FromHex(Constants.ColorPrimary), IsVisible = App.Bought }; string verifyLabelText = "", thanksLabelText = ""; stack1.Children.Add(verifyimage); stack1.Children.Add(verifyLabel); stack1.Children.Add(thanksLabel); layout.Children.Add(stack1); stack1.BackgroundColor = Color.White; stack1.Padding = paddingTB; layout.Spacing = 10; scroll.Content = layout; if (proapi.code == 444 || proapi.code == 400 || proapi.code == 445) { verifyimage.Source = "icon_result_2"; verifyLabelText = "SẢN PHẨM KHÔNG CÓ TRONG HỆ THỐNG"; thanksLabelText = "Bạn hãy cẩn thận"; verifyLabel.Text = verifyLabelText; verifyLabel.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)); verifyLabel.HorizontalOptions = LayoutOptions.CenterAndExpand; thanksLabel.Text = thanksLabelText; thanksLabel.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)); thanksLabel.HorizontalOptions = LayoutOptions.CenterAndExpand; } else { if (dataresult.product.ite_status == "3") { verifyimage.Source = "icon_result_3"; verifyLabelText = "SẢN PHẨM CHÍNH HÃNG"; thanksLabelText = "Cảm ơn bạn đã mua hàng"; verifyLabel.TextColor = Color.Green; thanksLabel.TextColor = Color.Green; App.Bought = true; } else if (dataresult.product.ite_status != "3" && proapi.changed == 0) { verifyimage.Source = "icon_result_1"; verifyLabelText = "SẢN PHẨM ĐÃ ĐƯỢC MUA"; thanksLabelText = "Ngày bán: " + pro.ite_soldtime; App.Bought = false; } else if (dataresult.product.ite_status != "3" && proapi.changed == 1) { verifyimage.Source = "icon_result_1"; verifyLabelText = "XIN CẢM ƠN BẠN ĐÃ MUA HÀNG"; thanksLabelText = "Vào lúc: " + pro.ite_soldtime; verifyLabel.TextColor = Color.Green; thanksLabel.TextColor = Color.Green; App.Bought = true; } Debug.WriteLine(verifyimage.Source.ToString()); verifyLabel.Text = verifyLabelText; verifyLabel.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)); verifyLabel.FontAttributes = FontAttributes.Bold; verifyLabel.HorizontalOptions = LayoutOptions.CenterAndExpand; thanksLabel.Text = thanksLabelText; thanksLabel.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)); thanksLabel.HorizontalOptions = LayoutOptions.CenterAndExpand; //Ảnh sản phẩm var proimage = new Image() { WidthRequest = App.Current.MainPage.Width / 3 }; if (dataresult.image != "") { proimage = new Image(); try { byte[] proimageBytes = Convert.FromBase64String(dataresult.image); proimage.Source = ImageSource.FromStream( () => new MemoryStream(proimageBytes)); } catch { proimage.Source = "icon_default"; } } else { proimage.Source = "icon_default"; } //Nội dung sản phẩm var productdetailStack = new StackLayout(); var itemnameLabel = new Label { Text = pro.pro_name, TextColor = Color.Black }; itemnameLabel.FontAttributes = FontAttributes.Bold; var stackitemcodeLabel = new StackLayout() { Orientation = StackOrientation.Horizontal }; var maSPLabel = new Label { Text = "Mã SP: ", TextColor = Color.Black, FontAttributes = FontAttributes.Bold }; var itemcodeLabel = new Label { Text = itemcode, TextColor = Color.Black }; var hotlineLabel = new Label { Text = "Hotline: " + hotline, TextColor = Color.Black }; stackitemcodeLabel.Children.Add(maSPLabel); stackitemcodeLabel.Children.Add(itemcodeLabel); productdetailStack.Children.Add(itemnameLabel); productdetailStack.Children.Add(stackitemcodeLabel); productdetailStack.Children.Add(hotlineLabel); productdetailStack.Children.Add(muaspButton); var grid = new Grid(); grid.RowDefinitions.Add(new RowDefinition { Height = Application.Current.MainPage.Width / 3 }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) }); grid.Children.Add(proimage, 0, 0); grid.Children.Add(productdetailStack, 1, 0); var stack2 = new StackLayout(); stack2.Children.Add(grid); stack2.Padding = paddingTB; stack2.BackgroundColor = Color.White; layout.Children.Add(stack2); var stackprivate = new StackLayout(); if (App.sessionId != null) { var privatetitle = new Label { Text = "THÔNG TIN NỘI BỘ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), FontAttributes = FontAttributes.Bold, TextColor = Color.Black }; var privategapBoxView = new BoxView { Color = Color.Gray, HeightRequest = 1, WidthRequest = (Application.Current.MainPage.Width / 7) * 6, VerticalOptions = LayoutOptions.Center }; var private_z = new Label() { Text = dataresult.product.private_z, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), //FontAttributes = FontAttributes.Bold, TextColor = Color.Black }; stackprivate.Children.Add(privatetitle); stackprivate.Children.Add(privategapBoxView); stackprivate.Children.Add(private_z); stackprivate.Padding = paddingTLR; stackprivate.BackgroundColor = Color.White; layout.Children.Add(stackprivate); } //Thông tin chi tiết sản phẩm var stack3 = new StackLayout(); var productdetailWebView = new WebView { Source = new HtmlWebViewSource { Html = @"<html><body>" + dataresult.product.pro_detail + "</body></html>" }, HeightRequest = 250, //MinimumHeightRequest = 100, WidthRequest = 1000 }; var productdetailtitleLabel = new Label { Text = "THÔNG TIN SẢN PHẨM", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), FontAttributes = FontAttributes.Bold, TextColor = Color.Black }; stack3.Children.Add(productdetailtitleLabel); var gapBoxView1 = new BoxView { Color = Color.Gray, HeightRequest = 1, WidthRequest = (Application.Current.MainPage.Width / 7) * 6, VerticalOptions = LayoutOptions.Center }; stack3.Children.Add(gapBoxView1); stack3.Children.Add(productdetailWebView); stack3.Padding = paddingTLR; stack3.BackgroundColor = Color.White; layout.Children.Add(stack3); //Mô tả công ty var stack4 = new StackLayout(); var companydetailview = new StackLayout(); var companytitleLabel = new Label { Text = "DOANH NGHIỆP SỞ HỮU", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), FontAttributes = FontAttributes.Bold, TextColor = Color.Black }; companydetailview.Children.Add(companytitleLabel); var gapBoxView = new BoxView { Color = Color.Gray, HeightRequest = 1, WidthRequest = (Application.Current.MainPage.Width / 7) * 6, VerticalOptions = LayoutOptions.Center }; companydetailview.Children.Add(gapBoxView); var companynameLabel = new Label { Text = "Tên công ty: " + dataresult.company.name, TextColor = Color.Black }; companydetailview.Children.Add(companynameLabel); var companyaddressLabel = new Label { Text = "Địa chỉ: " + dataresult.company.addr, TextColor = Color.Black }; companydetailview.Children.Add(companyaddressLabel); var companyphoneLabel = new Label { Text = "Điện thoại: " + dataresult.company.mobile, TextColor = Color.Black }; companydetailview.Children.Add(companyphoneLabel); var companyemailLabel = new Label { Text = "Email: " + dataresult.company.email, TextColor = Color.Black }; companydetailview.Children.Add(companyemailLabel); var companywebsiteLabel = new Label { Text = "Website: " + dataresult.company.website, TextColor = Color.Black }; companydetailview.Children.Add(companywebsiteLabel); stack4.Children.Add(companydetailview); var endBoxView = new BoxView { BackgroundColor = Color.FromHex(color_theme), HeightRequest = 50 }; stack4.Padding = paddingTLR; stack4.BackgroundColor = Color.White; layout.Children.Add(stack4); layout.Children.Add(endBoxView); //Lưu dự liệu scan vào lịch sử //DateTime now = DateTime.Now.ToLocalTime(); string datestring = DateTime.Now.ToString("dd/MM/yy HH:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture); Debug.WriteLine(datestring); HistoryScanItem scannedItem = new HistoryScanItem() { itemcode = itemcode, itemname = pro.pro_name, itemimage = image.image, companyname = com.name, datetime = datestring }; Debug.WriteLine("active database"); //App.HDatabase.DeleteAllAsync(); await App.HDatabase.SaveItemAsync(scannedItem); App.AppHSI.Insert(0, scannedItem);//xử lý listview android Debug.WriteLine("database save done!"); disback = false; muaspButton.Clicked += async delegate(object sender, EventArgs e) { //var confirmgrid = grid; await Navigation.PushPopupAsync(new BuyDialog(dataresult.image, itemcode, hotline, pro.pro_name)); }; //var locationresp; Debug.WriteLine("active location"); var location = new LocationAPI(); Device.BeginInvokeOnMainThread(async() => { location = await App.SvLocationManager.GetLocationAsync(); try { await App.SvLocationManager.UpdateLocationAsync(location, true, itemcode); } catch (Exception ex) { Debug.WriteLine("ko lưu đc location " + ex); } } ); Device.StartTimer(TimeSpan.FromSeconds(0.1), () => { // Do something //Debug.WriteLine("Chỉ số đã mua: " + App.Bought); if (App.Bought == false) { muaspButton.IsVisible = false; } //Nút mua sẽ luôn hiển thị khi giá trị bought là false (đã mua) if (App.Bought == false && App.soldtime != null) { //giá trị text chỉ thực hiện thay đổi sau khi đã click vào nút mua tức giá trị soldtime sẽ thay đổi //App soldtime sẽ được khai báo null khi tạo mới một resultpage và sẽ được gán giá trị mới khi click vào mua hàng //verifyimage.Source = "icon_result_1"; verifyLabel.Text = "XIN CẢM ƠN BẠN ĐÃ MUA HÀNG"; thanksLabel.Text = "Ngày bán: " + App.soldtime; return(false); } return(true); // True = Repeat again, False = Stop the timer }); } Content = scroll; } catch (Exception ex) { Debug.WriteLine(ex); Debug.WriteLine("Type" + ex.GetType()); if (ex.GetType().ToString() == "System.NotImplementedException") { CheckLoadingInit(itemcode); } Content = SetErrorPage(); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="client">操作类</param> public LocationInterface(Client client) : base(client) { api = new LocationAPI(client); }
public Task UpdateLocationAsync(LocationAPI location, bool isNewLocation, string itemcode) { return(getlocation.PerformUpdateLocationAsync(location, isNewLocation, itemcode)); }
private void Edit(int locationId) { locationApi = new LocationAPI(); }
Location InterfaceLocation.GetLocationByName(string Name) { LocationAPI locationAPI = new LocationAPI(); return(locationAPI.GetLocationByName(Name)); }
bool InterfaceLocation.UpdateLocation(Location location) { LocationAPI locationAPI = new LocationAPI(); return(locationAPI.UpdateLocation(location.Id, location.LocationName, location.LocationDescription, location.LocationType)); }
bool InterfaceLocation.DeleteLocation(int id) { LocationAPI locationAPI = new LocationAPI(); return(locationAPI.DeleteLocation(id)); }
public RecipeEditViewModel(int recipeId) { this.recipeId = recipeId; recipeApi = new RecipeAPI(); var recipeProduct = recipeApi.Get(this.recipeId); this.name = recipeProduct.Name; this.description = recipeProduct.Description; SaveCommand = new Command(Save); #region Продукты var productsRecipe = recipeProduct.Products.Select(x => new Model.ProductRecipe() { ProductId = x.ProductId, ProductName = x.ProductName, Value = x.Value, AddCommand = new Command((() => AddProduct(x.ProductId))), RemoveCommand = new Command((() => RemoveProduct(x.ProductId))) }); ProductsRecipe = new ObservableCollection <ProductRecipe>(productsRecipe); var productsApi = new ProductsAPI(); var products = productsApi.GetAll().Select(x => new ProductRecipe() { ProductId = x.Id, ProductName = x.Name, Value = 0, AddCommand = new Command((() => AddProduct(x.Id))), RemoveCommand = new Command((() => RemoveProduct(x.Id))) }); Products = new ObservableCollection <ProductRecipe>(); foreach (var product in products) { if (ProductsRecipe.All(p => p.ProductId != product.ProductId)) { Products.Add(product); } } #endregion #region Локации var recipeLocations = recipeApi.GetLocations(this.recipeId); var locationsRecipe = recipeLocations.Locations.Select(x => new Model.Location() { Id = x.Id, Name = x.Name, AddCommand = new Command((() => AddLocation(x.Id))), RemoveCommand = new Command((() => RemoveLocation(x.Id))) }); LocationsRecipe = new ObservableCollection <Model.Location>(locationsRecipe); var locationApi = new LocationAPI(); var locations = locationApi.GetAll().Select(x => new Model.Location() { Id = x.Id, Name = x.Name, AddCommand = new Command((() => AddLocation(x.Id))), RemoveCommand = new Command((() => RemoveLocation(x.Id))) }); Locations = new ObservableCollection <Model.Location>(); foreach (var location in locations) { if (LocationsRecipe.All(l => l.Id != location.Id)) { Locations.Add(location); } } #endregion }
List <string> InterfaceLocation.GetLocationsName() { LocationAPI locationAPI = new LocationAPI(); return(locationAPI.GetLocationsName()); }