public bool CreateServiceEstimate(ServiceEstimateCreate model)
        {
            var entity =
                new ServiceEstimate()
            {
                BayId           = _bayId,
                VehicleId       = model.VehicleId,
                ServicePartCost = model.ServicePartCost,
                VehicleMake     = model.VehicleMake,
                ServiceNotes    = model.ServiceNotes,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.ServiceEstimates.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Esempio n. 2
0
        public ActionResult Create(ServiceEstimateCreate serviceEstimate)
        {
            if (!ModelState.IsValid)
            {
                return(View(serviceEstimate));
            }

            var service = CreateServiceEstimateService();

            if (service.CreateServiceEstimate(serviceEstimate))
            {
                TempData["SaveResult"] = "Estimate added to profile created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Estimate could not be created");

            return(View(serviceEstimate));
        }