// Create public bool CreatePayingBy(PayingByCreate model) { var entity = new PayingBy() { CashOrCard = model.CashOrCard }; using (var ctx = new ApplicationDbContext()) { ctx.Payments.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(PayingByCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = new PayingByService(); if (service.CreatePayingBy(model)) { TempData["SaveResult"] = "Ppayment Created"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Payment could not be added"); return(View(model)); }