예제 #1
0
        public ActionResult EditUser(int id)
        {
            var repo = VehicleRepoFactory.Create();
            var emp  = repo.GetEmployeeByID(id);

            return(View(emp));
        }
예제 #2
0
        public ActionResult ContactUs(ContactUs ct)
        {
            var repo    = VehicleRepoFactory.Create();
            var context = new CarDealershipDBContext();

            if (ModelState.IsValid)
            {
                ContactUs contact = new ContactUs
                {
                    ContactUsID = ct.ContactUsID,
                    Email       = ct.Email,
                    FirstName   = ct.FirstName,
                    LastName    = ct.LastName,
                    Message     = ct.Message,
                    Phone       = ct.Phone,
                    Date        = DateTime.Now
                };
                repo.AddContact(contact);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View(ct));
            }
        }
예제 #3
0
        public ActionResult VehicleDetails(int id)
        {
            var     repo  = VehicleRepoFactory.Create();
            Vehicle model = new Vehicle();

            model = repo.GetVehicleByID(id);
            return(View(model));
        }
예제 #4
0
        public ActionResult AddMake(Make m)
        {
            m.AddedDate = DateTime.Today.Date;
            m.AddedBy   = User.Identity.Name;
            var repo = VehicleRepoFactory.Create();

            repo.AddMake(m);

            return(RedirectToAction("Makes", "admin"));
        }
예제 #5
0
        public ActionResult EditUser(Employee emp)
        {
            CarDealershipDBContext context = new CarDealershipDBContext();
            var userMgr = new UserManager <AppUser>(new UserStore <AppUser>(context));
            var repo    = VehicleRepoFactory.Create();

            var user = userMgr.FindByName(emp.OldUserName);

            {
                user.UserName = emp.UserName;
                user.Email    = emp.Email;
            };
            userMgr.Update(user);
            userMgr.ChangePassword(user.Id, emp.OldPassword, emp.Password);

            repo.EditEmployee(emp);
            return(RedirectToAction("Users", "admin"));
        }
예제 #6
0
        public ActionResult AddUser(Employee m)
        {
            CarDealershipDBContext context = new CarDealershipDBContext();
            var repo = VehicleRepoFactory.Create();

            var userMgr = new UserManager <AppUser>(new UserStore <AppUser>(context));

            if (!userMgr.Users.Any(u => u.UserName == m.UserName))
            {
                var newUser = new AppUser()
                {
                    UserName = m.UserName,
                    Email    = m.Email
                };
                userMgr.Create(newUser, m.Password);
                context.SaveChanges();
                userMgr.AddToRole(newUser.Id, m.Role);
                repo.AddEmployee(m);
            }
            return(RedirectToAction("Index", "Home"));
        }
예제 #7
0
        public IHttpActionResult vehicleModels(string make)
        {
            var repo = VehicleRepoFactory.Create();

            return(Ok(repo.GetModelsByMake(make)));
        }
예제 #8
0
        public IHttpActionResult vehicleVin(string vin)
        {
            var repo = VehicleRepoFactory.Create();

            return(Ok(repo.GetVehicleByVin(vin)));
        }
예제 #9
0
        public IHttpActionResult vehicleDetails(int id)
        {
            var repo = VehicleRepoFactory.Create();

            return(Ok(repo.GetVehicleByID(id)));
        }
예제 #10
0
        public IHttpActionResult QuickSearch(string Type, string SearchKey, int YearMin, int YearMax, int PriceMin, int PriceMax)
        {
            var repo = VehicleRepoFactory.Create();

            return(Ok(repo.QuickSearch(Type, SearchKey, YearMin, YearMax, PriceMin, PriceMax)));
        }
예제 #11
0
        public IHttpActionResult Get()
        {
            var repo = VehicleRepoFactory.Create();

            return(Ok(repo.GetFeaturedVehicles()));
        }
예제 #12
0
        public IHttpActionResult GetAll()
        {
            var repo = VehicleRepoFactory.Create();

            return(Ok(repo.GetSpecials()));
        }