public async Task <IActionResult> Edit(Guid id, [Bind("Id,EstimateId,Item,Description,Quantity,Price,Discount,Amount,DateCreated,DateUpdated,DateModified,IsDeleted")] ItemsEIR itemsEIR) { if (id != itemsEIR.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(itemsEIR); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemsEIRExists(itemsEIR.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EstimateId"] = new SelectList(_context.Estimates, "Id", "Id", itemsEIR.EstimateId); return(View(itemsEIR)); }
public async Task <IActionResult> AddItemEIR([Bind("Id,EstimateId,Item,Description,Quantity,Price,Discount,Amount,DateCreated,DateUpdated,DateModified,IsDeleted")] ItemsEIR itemsEIR) { if (ModelState.IsValid) { itemsEIR.Id = Guid.NewGuid(); _context.Add(itemsEIR); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //ViewData["EstimateId"] = new SelectList(_context.Estimates, "Id", "Id", itemsEIR.EstimateId); return(View()); }
public ActionResult AddItem([FromBody] Items Item) { ItemsEIR singleItem = new ItemsEIR() { Id = Guid.NewGuid(), EstimateId = Item.EstimateId, Item = Item.Item, Description = Item.Description, Quantity = float.Parse(Item.Quantity), Price = float.Parse(Item.UnitCost), Amount = float.Parse(Item.Quantity) * float.Parse(Item.UnitCost), }; _context.Add(singleItem); _context.SaveChanges(); return(Json(new { msg = "Successfully added." })); }