Exemplo n.º 1
0
        public ActionResult Create(CarClassVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            _carService.CreateCar(Transform.FromViewModelToModelCar(model));

            DetailsEmailVM email = new DetailsEmailVM(Constants.DETAILS_EMAIL)
            {
                Subject   = "subject",
                ToAddress = "*****@*****.**",
                Id        = int.Parse(model._Year),
                FirstName = model._maker,
                LastName  = model._model
            };

            try
            {
                _emailService.Send(email);
            }
            catch (Exception e)
            {
                return(View());
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 public static CarClass FromViewModelToModelCar(CarClassVM carModel)
 {
     return(new CarClass()
     {
         _Id = carModel._Id,
         _model = carModel._model,
         _maker = carModel._maker,
         _Year = carModel._Year
     });
 }
Exemplo n.º 3
0
 public ActionResult Delete(Guid id, CarClassVM collection)
 {
     try
     {
         // TODO: Add delete logic here
         _carService.DeleteCar(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 4
0
        public ActionResult Edit(Guid id, CarClassVM collection)
        {
            try
            {
                // TODO: Add update logic here
                _carService.UpdateCar(id, Transform.FromViewModelToModelCar(collection));

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }