public ActionResult Add(InvoiceDto newInvoice) { try { newInvoice.Id = _invoiceService.Insert(newInvoice); return RedirectToAction("View", new { Id = newInvoice.Id }); } catch { ViewBag.FormMode = "Add"; ViewBag.ClientList = new SelectList(_clientService.FetchSellableLookup(), "Id", "FullName"); ViewBag.InvoiceTypeFilter = EnumHelper.InvoiceTypeToEnum(newInvoice.InvoiceType); return View("Edit"); } }
public void Update(InvoiceDto editedItem) { //Begin DB transaction _invoiceDb.BeginTransaction(); try { //Get record _invoiceDb.Update(Mapper.Map<InvoiceDto, InvoiceDomain>(editedItem)); _invoiceDb.CompleteTransaction(); Logger.Info(String.Format("Invoice #{0} Updated Successfully", editedItem.Id)); } catch (Exception ex) { Logger.Error(ex); _invoiceDb.AbortTransaction(); throw; } }
public ActionResult Edit(int id, InvoiceDto editedInvoice) { try { _invoiceService.Update(editedInvoice); return RedirectToAction("View", new { Id = editedInvoice.Id }); } catch { ViewBag.FormMode = "Edit"; ViewBag.ClientList = new SelectList(_clientService.FetchSellableLookup(), "Id", "FullName"); ViewBag.InvoiceTypeFilter = EnumHelper.InvoiceTypeToEnum(editedInvoice.InvoiceType); return View(); } }
public int Insert(InvoiceDto newRecord) { //Begin DB transaction _invoiceDb.BeginTransaction(); try { //Insert record var invoiceId = _invoiceDb.Insert(Mapper.Map<InvoiceDto, InvoiceDomain>(newRecord)); _invoiceDb.CompleteTransaction(); Logger.Info(String.Format("{0} '{1}' Inserted Successfully", newRecord.InvoiceType, newRecord.InvoiceNumber)); return invoiceId; } catch (Exception ex) { Logger.Error(ex); _invoiceDb.AbortTransaction(); throw; } }