Пример #1
0
        public IHttpActionResult ContactVIN(string VIN)
        {
            var repo = GuildCarsRepositoryFactory.GetRepository();

            try
            {
                repo.ContactUs(VIN);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #2
0
        public IHttpActionResult GetSpecials()
        {
            var repo = GuildCarsRepositoryFactory.GetRepository();

            try
            {
                var result = repo.GetSpecials();
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #3
0
        public ActionResult PostSpecial(Special special)
        {
            if (!ModelState.IsValid)
            {
                //return BadRequest(ModelState);
            }

            GuildCarsRepositoryFactory.GetRepository().AddSpecial(special);
            //db.SaveChanges();

            return(View("AddSpecials"));
            //return Created($"api/Dvds1/{dvd.DvdId})", dvd);
            //return null;
            //return CreatedAtRoute("DefaultApi", new { id = dvd.DvdId }, dvd);
        }
Пример #4
0
        // GET: api/Dvds1/5
        public ActionResult Details(int CarId)
        {
            Car car = GuildCarsRepositoryFactory.GetRepository().GetById(CarId);

            if (car.PurchaseDate != null)
            {
                ViewBag.purchased = car.PurchaseDate;
            }
            else
            {
                ViewBag.purchaseId = null;
            }

            return(View(car));
        }
Пример #5
0
        // POST: api/Dvds1
        public ActionResult PostCar(Car car)
        {
            if (!ModelState.IsValid)
            {
                //return BadRequest(ModelState);
            }

            GuildCarsRepositoryFactory.GetRepository().Insert(car);
            //db.SaveChanges();

            return(View());
            //return Created($"api/Dvds1/{dvd.DvdId})", dvd);
            //return null;
            //return CreatedAtRoute("DefaultApi", new { id = dvd.DvdId }, dvd);
        }
Пример #6
0
        public ActionResult EditUser(string id)
        {
            var model = new UserEditViewModel();

            var Repo = GuildCarsRepositoryFactory.GetRepository();

            var user = Repo.GetUser(id);

            model.User = user;

            var roleRepo = GuildCarsRepositoryFactory.GetRepository();

            model.Role = new SelectList(roleRepo.GetRoles(), "Id", "Name");

            return(View(model));
        }
Пример #7
0
        public ActionResult PostMake(Make make)
        {
            var currentUser = User.Identity.GetUserName();

            if (!ModelState.IsValid)
            {
                //return BadRequest(ModelState);
            }

            GuildCarsRepositoryFactory.GetRepository().AddMake(make, currentUser);
            //db.SaveChanges();

            return(View("AddMake"));
            //return Created($"api/Dvds1/{dvd.DvdId})", dvd);
            //return null;
            //return CreatedAtRoute("DefaultApi", new { id = dvd.DvdId }, dvd);
        }
Пример #8
0
        public ActionResult PostUser(UserEditViewModel uviewModel)
        {
            //var roleName = uviewModel.User.RoleName;

            var user = uviewModel.User;

            string id = uviewModel.User.Id;

            Guid guidid = Guid.NewGuid();

            AddUser addUser = new AddUser();

            addUser.Id                   = guidid.ToString();
            addUser.FirstName            = user.FirstName;
            addUser.LastName             = user.LastName;
            addUser.Email                = user.Email;
            addUser.EmailConfirmed       = 1;
            addUser.AccessFailedCount    = 1;
            addUser.LockOutEnabled       = 1;
            addUser.PhoneNumberConfirmed = 1;
            addUser.TwoFactorEnabled     = 1;
            addUser.UserName             = "******";

            if (!ModelState.IsValid)
            {
                //return BadRequest(ModelState);
            }

            GuildCarsRepositoryFactory.GetRepository().AddUser(addUser);

            var userNew = GuildCarsRepositoryFactory.GetRepository().GetUser(id);

            var userId = userNew.Id;
            var roleId = userNew.RoleId;

            GuildCarsRepositoryFactory.GetRepository().AddUserRole(roleId, userId);
            //db.SaveChanges();

            var model = GuildCarsRepositoryFactory.GetRepository().GetUsers();

            return(View("Users", model));
            //return Created($"api/Dvds1/{dvd.DvdId})", dvd);
            //return null;
            //return CreatedAtRoute("DefaultApi", new { id = dvd.DvdId }, dvd);
        }
Пример #9
0
        public ActionResult Purchase(int id)
        {
            var cardetails = GuildCarsRepositoryFactory.GetRepository().GetById(id);

            ViewBag.carid = cardetails.CarId;

            var model = new PurchaseAddViewModel();

            var Repo = GuildCarsRepositoryFactory.GetRepository();

            model.States        = new SelectList(Repo.GetStates(), "StateId", "StateName");
            model.PurchaseTypes = new SelectList(Repo.GetPurchaseTypes(), "PurchaseTypeId", "PurchaseTypeName");
            model.Car           = cardetails;
            model.Purchase      = new Purchase();
            model.Contact       = new Contact();

            return(View(model));
        }
Пример #10
0
        public ActionResult AddVehicle()
        {
            var model = new VehicleAddViewModel();

            var Repo = GuildCarsRepositoryFactory.GetRepository();

            model.Make         = new SelectList(Repo.GetMakes(), "MakeId", "MakeName");
            model.Model        = new SelectList(Repo.GetModels(), "ModelId", "ModelName");
            model.Interior     = new SelectList(Repo.GetInteriors(), "Id", "InteriorName");
            model.Transmission = new SelectList(Repo.GetTransmissions(), "Id", "TransName");
            model.Color        = new SelectList(Repo.GetColors(), "Id", "ColorName");
            model.BodyStyle    = new SelectList(Repo.GetBodyStyles(), "Id", "BodyStyleName");
            model.CarType      = new SelectList(Repo.GetCarTypes(), "Id", "CarTypeName");
            model.States       = new SelectList(Repo.GetStates(), "StatesId", "StatesName");

            model.Car = new Car();

            return(View(model));
        }
Пример #11
0
        public IHttpActionResult SalesReport(DateTime?toDate, DateTime?fromDate, string userName)
        {
            var repo = GuildCarsRepositoryFactory.GetRepository();

            try
            {
                var parameters = new SalesReportParameters
                {
                    UserName = userName,
                    ToDate   = toDate,
                    FromDate = fromDate
                };

                var result = repo.SalesReport(parameters);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #12
0
        public IHttpActionResult SearchAdmin(string magicTerm, decimal?maxPrice, decimal?minPrice, string minYear, string maxYear)
        {
            var repo = GuildCarsRepositoryFactory.GetRepository();

            try
            {
                var parameters = new CarSearchParameters
                {
                    MagicTerm  = magicTerm,
                    MaxPrice   = maxPrice,
                    MinPrice   = minPrice,
                    MinMfgYear = minYear,
                    MaxMfgYear = maxYear
                };

                var result = repo.SearchSales(parameters);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #13
0
        public ActionResult PostModel(Model model)
        {
            var currentUser = User.Identity.GetUserName();

            if (!ModelState.IsValid)
            {
                //return BadRequest(ModelState);
            }

            GuildCarsRepositoryFactory.GetRepository().AddModel(model, currentUser);
            //db.SaveChanges();

            var model1 = new ModelEditViewModel();

            var makeRepo = GuildCarsRepositoryFactory.GetRepository();

            model1.Make  = new SelectList(makeRepo.GetMakes(), "MakeId", "MakeName");
            model1.Model = new Model();

            return(View("AddModel", model1));
            //return Created($"api/Dvds1/{dvd.DvdId})", dvd);
            //return null;
            //return CreatedAtRoute("DefaultApi", new { id = dvd.DvdId }, dvd);
        }
Пример #14
0
        // DELETE: api/Dvds1/5
        public ActionResult DeleteCar(int carId)
        {
            Car car = GuildCarsRepositoryFactory.GetRepository().GetById(carId);

            if (car == null)
            {
                //return NotFound();
            }

            GuildCarsRepositoryFactory.GetRepository().Delete(carId);
            return(View());

            /*Dvd dvd = db.Dvds.Find(id);
             * if (dvd == null)
             * {
             *  return NotFound();
             * }
             *
             * db.Dvds.Remove(dvd);
             * db.SaveChanges();
             *
             * return Ok(dvd);
             */
        }
Пример #15
0
        // GET: api/Dvds1/5
        public ActionResult GetById(int carId)
        {
            Car car = GuildCarsRepositoryFactory.GetRepository().GetById(carId);

            return(View(car));
        }
Пример #16
0
        public ActionResult _GetModels()
        {
            var model = GuildCarsRepositoryFactory.GetRepository().GetModels();

            return(View("_ModelList", model));
        }
Пример #17
0
        public ActionResult Users()
        {
            var model = GuildCarsRepositoryFactory.GetRepository().GetUsers();

            return(View("Users", model));
        }