public async Task <ActionResult <ReturnedProduct> > Post(ReturnedProduct product) { _db.ReturnedProducts.Update(product); await _db.SaveChangesAsync(); return(CreatedAtAction(nameof(GetSingle), new { id = product.Id }, product)); }
public async Task <IActionResult> Put(long id, ReturnedProduct product) { if (id != product.Id) { return(BadRequest()); } _db.Entry(product).State = EntityState.Modified; await _db.SaveChangesAsync(); return(NoContent()); }
public async Task <ManageStockPostApiResponse> ReceiveStock() { this.ProgressDialogMessage = this._deviceResource.PleaseWait; this.IsBusy = true; ReturnedProduct product = new ReturnedProduct { DsrPhone = this.DsrPhoneNumber, PersonId = this.DsrStock.PersonId, PersonRoleId = this.DsrStock.PersonRoleId }; product.Reason = this.SelectedReason.Reason; List <List <DeviceAllocationItem> > groupedSelectedList = this.SelectedUnits.GroupBy(u => u.ProductTypeId).Select(grp => grp.ToList()).ToList(); List <ScmStock> returnObj = new List <ScmStock>(); foreach (List <DeviceAllocationItem> products in groupedSelectedList) { ScmStock stock = new ScmStock(); stock.ProductTypeId = products[0].ProductTypeId; stock.Name = products[0].HeaderText; List <string> units = new List <string>(); foreach (var item in products) { units.Add(item.SerialNumber); } stock.SerialNumbers = units; returnObj.Add(stock); } product.Units = returnObj; ManageStockPostApiResponse response = await this.DsrStockAllocationService.ReceiveStockFromDsr(product); this.IsBusy = false; if (response == null) { return(new ManageStockPostApiResponse { Success = false, Text = "Units could not be returned." }); } return(response); }