public async Task <ApiResult <UpdateReturn> > GetByUpdateProduct(int id) { var product = await _context.Products.FindAsync(id); if (product == null) { return(new ApiErrorResult <UpdateReturn>("Sản phẩm không tồn tại")); } var query = await(from s in _context.Products join g in _context.ProductTypes on s.IdProductType equals g.Id where s.Id == id select new { g.Name }).FirstAsync(); var result = new UpdateReturn() { Id = product.Id, Code = product.Code, Name = product.Name, Image = product.Image, NameProductType = query.Name, Description = product.Description }; return(new ApiSuccessResult <UpdateReturn>(result)); }
public async Task <ApiResult <UpdateReturn> > Update(int id, ProductUpdate bundle) { ApiResult <UpdateReturn> result; if (bundle.Image != null) { var product = new UpdateReturn() { Id = bundle.Id, Code = bundle.Code, Description = bundle.Description, Name = bundle.Name, IdProductType = bundle.IdProductType }; var json = JsonConvert.SerializeObject(product); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var url = $"/api/product/" + $"{id}"; result = await Update <UpdateReturn>(url, httpContent); var image = await this.UpdateImage(id, bundle.Image); result.ResultObj.Image = image.ResultObj; } else { var json = JsonConvert.SerializeObject(bundle); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var url = $"/api/product/" + $"{id}"; result = await Update <UpdateReturn>(url, httpContent); } return(result); }
public static void UpdateReturnList(string UIName, string Message, bool ClearItems) { ListBox lsbTemp; Form form; try { form = Application.OpenForms["FormTerminal"]; if (form == null) { return; } lsbTemp = form.Controls.Find(UIName, true).FirstOrDefault() as ListBox; if (lsbTemp == null) { return; } if (lsbTemp.InvokeRequired) { UpdateReturn ph = new UpdateReturn(UpdateReturnList); lsbTemp.BeginInvoke(ph, UIName, Message, ClearItems); } else { if (ClearItems) { lsbTemp.Items.Clear(); } else { lsbTemp.Items.Insert(0, Message); lsbTemp.SelectedIndex = 0; } } } catch (Exception e) { logger.Error("UpdateReturnList: Update fail." + e.Message + "\n" + e.StackTrace); } }
public Updater() { InitializeComponent(); textBoxX1.Text = "Checking X360..."; UpdateReturn xReturn = XAbout.CheckForUpdate(); if (!xReturn.ServerReached) { textBoxX2.Text = "X360: Error"; } else if (xReturn.NeedsUpdate) { textBoxX2.Text = "X360: Not Up-To-Date"; textBoxX4.Text += "\r\nX360: " + xReturn.UpdateNotes + "\r\n"; buttonX1.Enabled = buttonX2.Enabled = true; } else { textBoxX2.Text = "X360: Current"; } textBoxX1.Text = "Checking Le Fluffie..."; try { StreamReader x = X360.Other.VariousFunctions.GetWebPageResponse("http://skunkiebutt.com/ProductCheck.php?product=Le Fluffie&command=read"); string version = x.ReadLine(); if ((version != Application.ProductVersion)) { textBoxX3.Text = "Le Fluffie: Not Up-To-Date"; UpdateLoc = x.ReadLine(); textBoxX4.Text += "\r\nLe Fluffie: " + x.ReadLine(); buttonX1.Enabled = buttonX2.Enabled = true; } else { textBoxX3.Text = "Le Fluffie: Current"; } x.Dispose(); } catch { textBoxX2.Text = "Le Fluffie: Error"; } textBoxX1.Text = "Status: Idle..."; }