Esempio n. 1
0
        public ActionResult Makes(MakesVM model)
        {
            _makeManager = MakeManagerFactory.Create();

            if (ModelState.IsValid)
            {
                try
                {
                    model.NewMake.DateAdded = DateTime.Now;
                    model.NewMake.UserName  = User.Identity.Name;

                    var response = _makeManager.SaveMake(model.NewMake);

                    if (!response.Success)
                    {
                        return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{response.Message}"));
                    }

                    return(RedirectToAction("Makes"));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                var response = _makeManager.GetAllMakes();
                model.SetMakeItems(response.Payload);

                return(View(model));
            }
        }
Esempio n. 2
0
        public ActionResult Makes()
        {
            _makeManager = MakeManagerFactory.Create();
            var model    = new MakesVM();
            var response = _makeManager.GetAllMakes();

            if (!response.Success)
            {
                return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{response.Message}"));
            }
            else
            {
                model.SetMakeItems(response.Payload);
                return(View(model));
            }
        }