public async Task <IActionResult> Create(int itemOfProductId, ItemExport itemExport) { var itemOfProduct = await _repository.GetItemOfProduct(itemOfProductId); if (itemOfProduct == null) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } if (await _repository.CheckIfImportsEqualExport(itemOfProductId, itemExport.Qty)) { ViewBag.ItemOfProductId = itemOfProduct.Id; ViewBag.ItemOfProductName = itemOfProduct.Name; return(View(itemExport).WithDanger("danger", "الكمية غير كافية")); } if (ModelState.IsValid) { _repository.Add <ItemExport>(itemExport); await _repository.SavaAll(); return(RedirectToAction(nameof(Index))); } ViewBag.ItemOfProductId = itemOfProduct.Id; ViewBag.ItemOfProductName = itemOfProduct.Name; return(View(itemExport)); }
public async Task <IActionResult> Edit(int id, ItemExport itemExport) { if (id != itemExport.Id) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } if (ModelState.IsValid) { try { _repository.Update <ItemExport>(itemExport); await _repository.SavaAll(); } catch (DbUpdateConcurrencyException) { if (_repository.GetItemExport(itemExport.Id) == null) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ItemOfProductId"] = new SelectList(await _repository.GetItemOfProducts(), "Id", "Name", itemExport.Id); return(View(itemExport)); }
public IHttpActionResult ItemExport([FromBody] ItemExport itemExport) { var product = db.Products.FirstOrDefault(x => x.ProductId == itemExport.PartNumber); Mapper.Map <ItemExport, Products>(itemExport, product); var currentDateTime = DateTime.Now; product.LastUpdate = currentDateTime; product.WmsUpdate = currentDateTime; product.LastAuthor = "Wms"; db.SaveChanges(); return(Ok()); }