public bool CreateTransaction(InvoiceTransactionCreate model) { var entity = new InvoiceTransaction() { OwnerId = _userId, InvoiceId = model.InvoiceId, ProductId = model.ProductId, }; using (var ctx = new ApplicationDbContext()) { ctx.InvoiceTransactions.Add(entity); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult CreateProduct(InvoiceTransactionCreate transaction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var svc = CreateTransactionService(); if (!svc.CreateTransaction(transaction)) { return(InternalServerError()); } return(Ok("201")); }
public ActionResult Create(InvoiceTransactionCreate model) { if (!ModelState.IsValid) { return(View(model)); } var svc = CreateInvoiceTransactionService(); if (svc.CreateTransaction(model)) { TempData["SaveResult"] = "Your product was created!"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Product was unable to be created"); return(View(model)); }