public void DeleteInvoice(Invoice invoice) { invoice.isDelete = true; invoice.UserInvoices.FirstOrDefault().isDelete = true; _invoiceRepository.Update(invoice); _unitOfWork.Commit(); int idInvoice = invoice.Id; #region [delete] var listItemInvoice = _invoiceItemRepository.GetMany(p => p.InvoiceId == idInvoice); foreach (var item in listItemInvoice) { item.Note = "1"; _invoiceItemRepository.Update(item); _unitOfWork.Commit(); } #endregion //var listUservoice = _userInvoiceRepository.GetAll().Where(p => p.InvoiceId == idInvoice); //foreach (var item in listUservoice) //{ // item.Note = "1"; // _userInvoiceRepository.Update(item); // _unitOfWork.Commit(); //} }
public async Task <IActionResult> Update([FromBody] InvoiceItemViewModel model) { if (model == null) { return(StatusCode(400, "Invalid parameter(s).")); } InvoiceItem invoiceItem = new InvoiceItem { InvoiceNumber = model.InvoiceNumber, ItemNumber = model.ItemNumber, Name = model.Name, Description = model.Description, Tax = model.Tax, Price = model.Price, Quantity = model.Quantity }; //Swap comma with dots var priceString = invoiceItem.Price.ToString().Replace(".", ","); invoiceItem.Price = Convert.ToDecimal(priceString); //Update invoice item var data = await _repo.Update(invoiceItem); if (data == null) { return(StatusCode(500, "A problem occured while updating the record. Please try again!")); } var result = new InvoiceItemViewModel(); result.SetProperties(data); return(Ok(result)); }
public void EditInvoiceItem(InvoiceItem invoiceItem) { //invoiceItem.isDelete = false; _invoiceItemRepository.Update(invoiceItem); _unitOfWork.Commit(); }
public void Update(InvoiceItemDto model) { _invoiceItemRepository.Update(model.Id, _mapper.Map <InvoiceItem>(model)); _invoiceItemRepository.SaveChanges(); }