Exemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            var service = CreateServiceEstimateService();
            var detail  = service.GetServiceEstimateById(id);
            var model   =
                new ServiceEstimateEdit
            {
                ServiceId       = detail.ServiceId,
                VehicleId       = detail.VehicleId,
                ServicePartCost = detail.ServicePartCost,
                ServiceNotes    = detail.ServiceNotes
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public bool UpdateServiceEstimate(ServiceEstimateEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .ServiceEstimates
                    .Single(e => e.ServiceId == model.ServiceId && e.BayId == _bayId);
                entity.ServiceId       = model.ServiceId;
                entity.VehicleId       = model.VehicleId;
                entity.ServicePartCost = model.ServicePartCost;
                //entity.ServiceLaborCost = model.SerciceLaborCost;
                entity.ServiceNotes = model.ServiceNotes;

                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id, ServiceEstimateEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.VehicleId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateServiceEstimateService();

            if (service.UpdateServiceEstimate(model))
            {
                TempData["SaveResult"] = "Estimate profile was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Estimate profile could not be updated.");
            return(View(model));
        }