public async Task PullPart(int partID, decimal Quantity) { Inventory _inventory = new Inventory() { DateStamp = DateTime.Today, PartID = partID, Qnty = Quantity * -1 }; await _db.Inventory.AddAsync(_inventory); await _db.SaveChangesAsync(); }
public async Task <IActionResult> OnPostAsync(PartEditDto Part) { if (!ModelState.IsValid) { return(Page()); } // Get the Part Entity-- Part _part = _context.Part.Find(Part.PartID); _part.PartNum = Part.PartNumber; _part.ItemName = Part.ItemName; // _part.PartTypeID = Part.PartTypeID; _part.SKU = Part.SKU; _part.SupplierID = Part.SupplierID; _part.UID = Part.UID; _part.UseSupplierNameFlag = Part.UseSupplierName; _part.SupplierDescription = Part.SupplierDescription; _part.Waste = Part.Waste; _part.Weight = Part.Weight; _part.MarkUp = Part.MarkUp; _part.Cost = Part.Cost; _part.AddedBy = Part.CreatedBy; _part.DateAdded = Part.DateAdded; _part.ModifiedBy = Part.ModifiedBy; _part.ModifiedDate = Part.LastModified.HasValue ? Part.LastModified.Value : DateTime.Today; _part.ItemDescription = Part.Description; _part.Location = Part.Location; _part.ManuID = Part.ManuID.Value; _part.AddedBy = Part.CreatedBy; //_context.Attach(_part).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!_context.Part.Any(e => e.PartID == _part.PartID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./index")); }