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));
            }
        }
        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));
            }
        }
Exemple #3
0
        public ActionResult Makes(MakesVM makesVM)
        {
            if (ModelState.IsValid)
            {
                var repo = CarMakesRepositoryFactory.GetRepository();

                var make = new CarMake();

                make.Name = makesVM.MakeName;

                repo.Insert(make);

                return(RedirectToAction("Makes"));
            }

            return(View("Makes", makesVM));
        }
        public ActionResult Makes()
        {
            var            makes      = CarDearlershipRespoFacotory.GetRepository().GetAllMakes();
            List <MakesVM> views      = new List <MakesVM>();
            var            usrManager = HttpContext.GetOwinContext().GetUserManager <UserManager <AppUser> >();


            foreach (var item in makes)
            {
                MakesVM view = new MakesVM();
                view.Created  = item.Created;
                view.MakeId   = item.MakeId;
                view.MakeName = item.MakeName;
                view.User     = usrManager.Users.Where(p => p.UsersInfo.Id == item.AdminId).First().Email;

                views.Add(view);
            }



            return(View(views));
        }
Exemple #5
0
        public ActionResult Makes()
        {
            var viewModel = new MakesVM();

            return(View(viewModel));
        }