public IActionResult AddVehicleModel(VehicleModelJsonModel model)
        {
            bool isAdded = false;

            if (!string.IsNullOrEmpty(model.Name))
            {
                model.Name = model.Name.Trim();
                isAdded    = _vehicleService.AddModel(model);
            }
            string error = isAdded ? Messages.INFO_ENTITY_ADDED : Messages.ERROR_ENTITY_EXISTS;

            return(Json(new ResponseJsonModel(isAdded, error: error)));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "ModelID, ModelName,MakeID ")] VehicleModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Service.AddModel(model);
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            ViewBag.MakeID = new SelectList(Service.GetMakers(), "MakeID", "MakerName", model.MakeID);

            return(View(model));
        }
Esempio n. 3
0
 public ActionResult Create(VehicleModelVM obj)
 {
     if (ModelState.IsValid)
     {
         string str = repository.AddModel(obj);
         if (str == "Ok")
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View());
         }
     }
     else
     {
         return(View());
     }
 }
Esempio n. 4
0
        public ActionResult Create(CreateViewModel vehicleModel)
        {
            vehicleModel.Makes = _vehicleService.GetMakes();

            if (!ModelState.IsValid)
            {
                return(View(vehicleModel));
            }

            var model = new VehicleModel()
            {
                MakeId    = vehicleModel.MakeId,
                ModelName = vehicleModel.ModelName
            };

            model.ModelId = _vehicleService.AddModel(model);

            return(View(vehicleModel));
        }