示例#1
0
        public Insurance Edit(int id, CreateInsuranceViewModel insurance)
        {
            Insurance editedInsurance = new Insurance()
            {
                Id = id, Name = insurance.Name, Price = insurance.Price
            };

            return(_insuranceRepo.Update(editedInsurance));
        }
        public ActionResult Edit(int id, CreateInsuranceViewModel createInsuranceViewModel)
        {
            if (ModelState.IsValid)
            {
                if (_insuranceService.Edit(id, createInsuranceViewModel) != null)
                {
                    return(RedirectToAction(nameof(Index)));
                }
                ModelState.AddModelError("System", "Failed to edit");
            }

            ViewBag.id = id;
            return(View(createInsuranceViewModel));
        }
        public ActionResult Create(CreateInsuranceViewModel createInsurance)
        {
            if (ModelState.IsValid)
            {
                Insurance insurance = _insuranceService.Add(createInsurance);
                if (insurance != null)
                {
                    return(RedirectToAction(nameof(Index)));
                }
                ModelState.AddModelError("System", "Create failed.");
            }

            return(View(createInsurance));
        }
示例#4
0
 public Insurance Add(CreateInsuranceViewModel createInsuranceViewModel)
 {
     return(_insuranceRepo.Create(createInsuranceViewModel.Name, createInsuranceViewModel.Price));
 }