예제 #1
0
        public void Save(InvoiceElementItem item)
        {
            item.GetValidationErrors().ThrowIfHasErrors();

            var element = item.Id == 0 ? Db.CreateAndAdd <InvoiceElement>() : Db.InvoiceElements.Single(x => x.Id == item.Id);

            element.Cost        = item.Cost;
            element.Description = item.Description;
            element.InvoiceElementCategoryId = item.InvoiceElementCategoryId;
            element.InvoiceId = item.InvoiceId;
            element.Qty       = item.Qty;

            Db.SaveChanges();

            item.CategoryName = Db.InvoiceElementCategories.Single(x => x.Id == item.InvoiceElementCategoryId).Name;
            item.Id           = element.Id;
        }
 public IActionResult SaveElement([FromBody] InvoiceElementItem item)
 {
     Service.InvoiceElement.Save(item);
     return(Ok(item));
 }