Пример #1
0
        public ActionResult Makes(MakesViewModel makes)
        {
            if (ModelState.IsValid)
            {
                var makesRepo = MakeFactory.GetRepository();

                makes.Make.UserID    = AuthorizeUtilities.GetUserId(this);
                makes.Make.DateAdded = DateTime.Now.ToString("MM/dd/yyyy");
                makesRepo.InsertMake(makes.Make);

                var allUsers = _context.Users.ToList();
                var allMakes = _context.Makes.ToList();

                makes.Makes   = makesRepo.GetMakes();
                makes.MakesVM = new List <MakesViewModel>();

                makes.MakesVM = allMakes.Select(x => new MakesViewModel
                {
                    MakeName  = x.MakeName,
                    DateAdded = x.DateAdded,
                    User      = allUsers.Where(y => y.Id == x.UserID).Select(y => y.Email).FirstOrDefault()
                }).ToList();

                return(View(makes));
            }
            else
            {
                return(View(makes));
            }
        }
        public ActionResult Makes(MakesViewModel model)
        {
            if (ModelState.IsValid)
            {
                var repo = MakesRepositoryFactory.GetRepository();

                try
                {
                    Makes make = new CarMastery.Models.Tables.Makes();
                    make.MakeDescription = model.MakeToAdd.MakeDescription;
                    make.UserId          = AuthorizeUtilities.GetUserId(this);
                    make.MakeDateAdded   = DateTime.Now;

                    repo.AddMake(make);

                    return(RedirectToAction("Makes"));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return(View(model));
            }
        }
Пример #3
0
        public ActionResult Index(int id, string orderBy = "Id")
        {
            var make       = _appDdContext.Makes.Single(m => m.MakeId == id);
            var query      = "SELECT * FROM MotorBikes WHERE MakeID = " + id + " ORDER BY " + orderBy;
            var motorBikes = _appDdContext.MotorBikes.FromSql(query);

            ViewBag.Make   = make.Name;
            ViewBag.MakeId = make.MakeId;

            Console.WriteLine(query);

            var allMakes = _appDdContext.Makes.AsEnumerable();
            var makeVM   = new MakesViewModel
            {
                MotorBikesForMake = motorBikes,
                AllMakes          = allMakes
            };

            if (motorBikes.Count() > 0 && orderBy.Length > 10)
            {
                Console.WriteLine("UNION INJECTION: {0}", query);
            }

            return(View(makeVM));
        }
Пример #4
0
        public ActionResult Makes()
        {
            var repo  = MakeRepositoryFactory.GetRepository();
            var model = new MakesViewModel();

            model.makes = repo.GetAll();
            return(View(model));
        }
        public ActionResult Makes()
        {
            var model = new MakesViewModel();
            var repo  = MakesRepositoryFactory.GetRepository();

            model.MakesList = repo.GetAllMakes().ToList();
            model.MakeToAdd = new Makes();
            return(View(model));
        }
Пример #6
0
        public MakesViewModel GetMakes()
        {
            MakesViewModel makes = new MakesViewModel
            {
                Makes = _context.Makes.Select(make => new MakesViewModel.Make
                {
                    MakeId = make.MakeId,
                    Name   = make.Name
                }).OrderBy(make => make.Name).ToList()
            };

            return(makes);
        }
Пример #7
0
        public ActionResult AddMake(MakesViewModel model)
        {
            model.newMake.UserName = this.User.Identity.Name;
            var repo = MakeRepositoryFactory.GetRepository();

            try
            {
                repo.Add(model.newMake);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            model       = new MakesViewModel();
            model.makes = repo.GetAll();
            return(View("Makes", model));
        }
Пример #8
0
        public ActionResult Makes()
        {
            var allUsers = _context.Users.ToList();
            var allMakes = _context.Makes.ToList();

            var model = new MakesViewModel();

            var makesRepo = MakeFactory.GetRepository();

            model.Makes   = makesRepo.GetMakes();
            model.MakesVM = new List <MakesViewModel>();

            model.MakesVM = allMakes.Select(x => new MakesViewModel
            {
                MakeName  = x.MakeName,
                DateAdded = x.DateAdded,
                User      = allUsers.Where(y => y.Id == x.UserID).Select(y => y.Email).FirstOrDefault()
            }).ToList();

            return(View(model));
        }