Exemplo n.º 1
0
        public ActionResult Create()
        {
            RequestViewModel request = new RequestViewModel();

            request.Request = new Request();

            MakesDataAccess makesDA = new MakesDataAccess();

            request.Makes  = makesDA.GetMakesList();
            request.Models = makesDA.GetModelsList();


            StatesDataAccess statesDA = new StatesDataAccess();

            request.States = statesDA.GetStatesList();

            UsersDataAccess usersDA = new UsersDataAccess();

            request.Users = usersDA.GetNonAdminUsers();

            Utils util = new Utils();

            request.Years = util.GetYearsList();
            return(View(request));
        }
Exemplo n.º 2
0
        public ActionResult HomeCreate()
        {
            RequestViewModel request = new RequestViewModel();

            request.Request = new Request();

            if (User.Identity.IsAuthenticated)
            {
                ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());

                request.Request.FirstName = user.FirstName;
                request.Request.LastName  = user.LastName;
                request.Request.phone     = user.PhoneNumber;
                request.Request.email     = user.Email;
            }

            MakesDataAccess makesDA = new MakesDataAccess();

            request.Makes  = makesDA.GetMakesList();
            request.Models = makesDA.GetModelsList();


            StatesDataAccess statesDA = new StatesDataAccess();

            request.States = statesDA.GetStatesList();


            Utils util = new Utils();

            request.Years = util.GetYearsList();
            return(View(request));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Request request = await db.Requests.FindAsync(id);

            if (request == null)
            {
                return(HttpNotFound());
            }
            RequestViewModel requestvm = new RequestViewModel();

            requestvm.Request = request;

            MakesDataAccess makesDA = new MakesDataAccess();

            requestvm.Makes  = makesDA.GetMakesList();
            requestvm.Models = makesDA.GetModelsList(request.Make.GetValueOrDefault());
            if (request.Make != null)
            {
                requestvm.SelectedMake = request.Make.GetValueOrDefault().ToString();
            }
            if (request.Model != null)
            {
                requestvm.SelectedModel = request.Model.GetValueOrDefault().ToString();
            }
            UsersDataAccess usersDA = new UsersDataAccess();

            requestvm.Users        = usersDA.GetNonAdminUsers();
            requestvm.SelectedUser = request.UserId;

            StatesDataAccess statesDA = new StatesDataAccess();

            requestvm.States = statesDA.GetStatesList();

            if (request.FromState != null)
            {
                requestvm.FromState = request.FromState.GetValueOrDefault().ToString();
            }
            if (request.ToState != null)
            {
                requestvm.ToState = request.ToState.GetValueOrDefault().ToString();
            }
            Utils util = new Utils();

            requestvm.Years        = util.GetYearsList();
            requestvm.SelectedYear = request.Year;

            return(View(requestvm));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> Edit(RequestViewModel rvm)
        {
            if (ModelState.IsValid)
            {
                Request request = new Request();
                request = rvm.Request;

                request.Make      = int.Parse(rvm.SelectedMake);
                request.Model     = int.Parse(rvm.SelectedModel);
                request.FromState = int.Parse(rvm.FromState);
                request.ToState   = int.Parse(rvm.ToState);
                request.Year      = rvm.SelectedYear;
                request.UserId    = rvm.SelectedUser;
                if (request.UserId == "0")
                {
                    request.UserId = null;
                }

                db.Entry(request).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            MakesDataAccess makesDA = new MakesDataAccess();

            rvm.Makes  = makesDA.GetMakesList();
            rvm.Models = makesDA.GetModelsList();

            UsersDataAccess usersDA = new UsersDataAccess();

            rvm.Users = usersDA.GetNonAdminUsers();

            StatesDataAccess statesDA = new StatesDataAccess();

            rvm.States = statesDA.GetStatesList();


            Utils util = new Utils();

            rvm.Years = util.GetYearsList();
            return(View(rvm));
        }