public async Task Edit(EditProductVMRequest entity) { var response = await _httpService.Put <EditProductVMRequest>(url, entity); if (!response.Success) { throw new ApplicationException(await response.GetBody()); } }
public async Task <ActionResult> Put(EditProductVMRequest entity) { #region Start the watch var watch = new Stopwatch(); watch.Start(); #endregion var result = await _entityServices.Put(entity); #region End the watch watch.Stop(); result.Meta.TotalProcessingTime = watch.ElapsedMilliseconds; #endregion return(Ok(result)); }
public async Task <ApiResponse> Put(EditProductVMRequest entity) { try { var entityDB = await _entityRepository.GetByIdAsync(entity.Id); var dbImages = JsonConvert.DeserializeObject <List <string> >(entityDB.Image); entityDB.Image = await HelpEditImages(entity.OldImages, entity.Images, dbImages, entityDB.Code); entityDB.Colors = HelpEditColors(entity.OldColors, entity.Colors); entityDB.StoreId = entity.StoreId; entityDB.CodeStore = entity.CodeStore; entityDB.Status = entity.Status; entityDB.CategoryId = entity.CategoryId; entityDB.Brand = entity.Brand; entityDB.Name = entity.Name; entityDB.Description = entity.Description; entityDB.MeasruingUnitId = entity.MeasruingUnitId; entityDB.Price = entity.Price; entityDB.Quantity1 = entity.Quantity1; entityDB.Price1 = entity.Price1; entityDB.Quantity2 = entity.Quantity2; entityDB.Price2 = entity.Price2; entityDB.Quantity3 = entity.Quantity3; entityDB.Price3 = entity.Price3; entityDB.CurrencyId = entity.CurrencyId; await _entityRepository.UpdateAsync(entityDB); return(ApiResponse.Create(HttpStatusCode.OK, null)); } catch (Exception) { return(ApiResponse.Create(HttpStatusCode.InternalServerError, null, "InternalServerError_Error")); } }