public async Task <ItemDTO> PatchAsync(ItemUpdateDTO item) { this.Logger.LogTrace($"{nameof(this.PutAsync)} called"); var result = await this.ItemUpdateService.UpdateAsync(this.Mapper.Map <ItemUpdateModel>(item)); return(this.Mapper.Map <ItemDTO>(result)); }
public ItemServiceTest() { unit = new Unit("as"); _itemService = new ItemService(_itemRepo.Object); _createDto = new ItemCreateDTO(); _updateDto = new ItemUpdateDTO(); _item = new Item(unit, item_name, 10); }
public async Task Update(ItemUpdateDTO dto) { using var tx = TransactionScopeHelper.GetInstance(); var item = await _itemRepo.GetById(dto.ItemId).ConfigureAwait(false) ?? throw new ItemNotFoundException(); item.Update(dto.Unit, dto.Name, dto.Price); await _itemRepo.UpdateAsync(item); tx.Complete(); }
public HttpResponseMessage UpdateItem(ItemUpdateDTO item) { try { dp.UpdateMapped <Item>(item); } catch (Exception ex) { var errorResponse = new HttpResponseMessage(HttpStatusCode.BadRequest); errorResponse.Content = new StringContent(ex.Message); return(errorResponse); } return(new HttpResponseMessage(HttpStatusCode.OK)); }
public async Task <ActionResult> Update(ItemUpdateViewModel model) { try { var Unit = await _unitRepo.GetById(model.UnitId).ConfigureAwait(true); var item = new ItemUpdateDTO { ItemId = model.ItemId, Name = model.Name, Price = model.Rate, Unit = Unit }; await _itemService.Update(item).ConfigureAwait(true); _toastNotification.AddInfoToastMessage("Successfully Updated to :- " + item.Name); } catch (Exception ex) { model.Units = (await _unitRepo.GetAllAsync().ConfigureAwait(true)).Where(a => a.IsActive()).ToList(); _toastNotification.AddErrorToastMessage("Error while in execution of update statement!"); } return(RedirectToAction("Index")); }