public async Task <IActionResult> PostPurchaseOrderdetail([FromBody] PurchaseOrderdetail purchaseOrderdetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.PurchaseOrderdetail.Add(purchaseOrderdetail); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (ProjectExists(purchaseOrderdetail.ProjectId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetPurchaseOrderdetail", new { id = purchaseOrderdetail.ProjectId }, purchaseOrderdetail)); }
public async Task <IActionResult> Create([Bind("ProjectId,OrderId,ProductId,Dimension,Description,Pattern,Colour,Quantity,Uom,UnitPrice,Amount,DeliveryStatus,OrderedBy,CreatedTime,UpdatedBy,UpdatedTime")] PurchaseOrderdetail purchaseOrderdetail) { if (ModelState.IsValid) { _context.Add(purchaseOrderdetail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["OrderedBy"] = new SelectList(_context.Employee, "UserId", "FirstName", purchaseOrderdetail.OrderedBy); ViewData["ProjectId"] = new SelectList(_context.PurchaseOrder, "ProjectId", "ProjectId", purchaseOrderdetail.ProjectId); ViewData["OrderId"] = new SelectList(_context.PurchaseOrder, "OrderId", "OrderId"); ViewData["UpdatedBy"] = new SelectList(_context.Employee, "UserId", "FirstName", purchaseOrderdetail.UpdatedBy); return(View(purchaseOrderdetail)); }
public async Task <IActionResult> Edit(int?projectId, int?orderId, string productId, [Bind("ProjectId,OrderId,ProductId,Dimension,Description,Pattern,Colour,Quantity,Uom,UnitPrice,Amount,DeliveryStatus,OrderedBy,CreatedTime,UpdatedBy,UpdatedTime")] PurchaseOrderdetail purchaseOrderdetail) { if (projectId != purchaseOrderdetail.ProjectId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(purchaseOrderdetail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PurchaseOrderdetailExists(purchaseOrderdetail.ProjectId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["OrderedBy"] = new SelectList(_context.Employee, "UserId", "FirstName", purchaseOrderdetail.OrderedBy); ViewData["ProjectId"] = new SelectList(_context.PurchaseOrder, "ProjectId", "ProjectId", purchaseOrderdetail.ProjectId); ViewData["OrderId"] = new SelectList(_context.PurchaseOrder, "OrderId", "OrderId"); ViewData["UpdatedBy"] = new SelectList(_context.Employee, "UserId", "FirstName", purchaseOrderdetail.UpdatedBy); return(View(purchaseOrderdetail)); }
public async Task <IActionResult> PutPurchaseOrderdetail([FromRoute] int projectId, int orderId, string productId, [FromBody] PurchaseOrderdetail purchaseOrderdetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (projectId != purchaseOrderdetail.ProjectId) { return(BadRequest()); } _context.Entry(purchaseOrderdetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectExists(projectId) && !OrderExists(orderId) && !ProductExists(productId)) { return(NotFound()); } else { throw; } } return(NoContent()); }