public ActionResult Create(RepairShopCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateRepairShopService();

            if (service.CreateRepairShop(model))
            {
                TempData["SaveResult"] = "Your ticket was created.";
                return(RedirectToAction("Index"));
            }
            ;

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

            return(View(model));
        }
Exemple #2
0
        public bool CreateRepairShop(RepairShopCreate model)
        {
            var entity =
                new RepairShop()
            {
                //RepairShopId = model.RepairShopId,
                CustomerId        = model.CustomerId,
                CustomerFirstName = model.CustomerFirstName,
                CustomerLastName  = model.CustomerLastName,
                VehicleId         = model.VehicleId,
                VehicleMake       = model.VehicleMake,
                VehicleModel      = model.VehicleModel,
                ServiceId         = model.ServiceId,
                ServiceTotalCost  = model.ServiceTotalCost
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.RepairShops.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }