Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ID,BodyDescription,ImageURL")] VehicleBody vehicleBody)
        {
            if (ModelState.IsValid)
            {
                db.VehicleBodies.Add(vehicleBody);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(vehicleBody));
        }
        public ActionResult Create([Bind(Include = "ID,VehicleMake1")] VehicleMake vehicleMake)
        {
            if (ModelState.IsValid)
            {
                db.VehicleMakes.Add(vehicleMake);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(vehicleMake));
        }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "ID,VehicleAdvertisementNextRefNo")] ConfigSetting configSetting)
        {
            if (ModelState.IsValid)
            {
                db.ConfigSettings.Add(configSetting);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(configSetting));
        }
        public ActionResult Create([Bind(Include = "ID,FuelType")] VehicleFuel vehicleFuel)
        {
            if (ModelState.IsValid)
            {
                db.VehicleFuels.Add(vehicleFuel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(vehicleFuel));
        }
        public ActionResult Create([Bind(Include = "ID,Description")] ViewPort viewPort)
        {
            if (ModelState.IsValid)
            {
                db.ViewPorts.Add(viewPort);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ID = new SelectList(db.ViewPortSettings, "ID", "SettingCode", viewPort.ID);
            return(View(viewPort));
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "ID,VehicleID,SellerID")] VehicleSeller vehicleSeller)
        {
            if (ModelState.IsValid)
            {
                db.VehicleSellers.Add(vehicleSeller);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SellerID  = new SelectList(db.Sellers, "ID", "Name", vehicleSeller.SellerID);
            ViewBag.VehicleID = new SelectList(db.VehicleAdvertisements, "Reference_ID", "Title", vehicleSeller.VehicleID);
            return(View(vehicleSeller));
        }
        public IHttpActionResult PutVehicleAdvertisement(int id, CarSalesVehicleAdvertisement carSalesVehicleAdvertisement)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carSalesVehicleAdvertisement.Reference_ID)
            {
                return(BadRequest());
            }

            VehicleAdvertisement vehicleAdvertisement = new VehicleAdvertisement()
            {
                AudoMeter      = carSalesVehicleAdvertisement.AudoMeter,
                BodyType       = carSalesVehicleAdvertisement.BodyType,
                Description    = carSalesVehicleAdvertisement.Description,
                EngineCapacity = carSalesVehicleAdvertisement.EngineCapacity,
                Feature        = carSalesVehicleAdvertisement.Feature,
                Fuel           = carSalesVehicleAdvertisement.Fuel,
                IsFeatured     = carSalesVehicleAdvertisement.IsFeatured,
                Make           = carSalesVehicleAdvertisement.Make,
                Model          = carSalesVehicleAdvertisement.Make,
                Price          = carSalesVehicleAdvertisement.Price,
                Reference_ID   = carSalesVehicleAdvertisement.Reference_ID,
                Reference_No   = carSalesVehicleAdvertisement.Reference_No,
                Spects         = carSalesVehicleAdvertisement.Spects,
                Title          = carSalesVehicleAdvertisement.Title,
                Transmission   = carSalesVehicleAdvertisement.Transmission
            };

            db.Entry(vehicleAdvertisement).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VehicleAdvertisementExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 8
0
        public ActionResult DeleteConfirmed(int id)
        {
            VehicleAdvertisement vehicleAdvertisement = db.VehicleAdvertisements.Find(id);

            db.VehicleAdvertisements.Remove(vehicleAdvertisement);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> SellerRegister(SellerRegisterModel model)
        {
            var identityUser = await UserManager.FindByNameAsync(model.ContactEMail);

            if (identityUser != null)
            {
                Seller seller = new Seller()
                {
                    AspNetUsersId = identityUser.Id,
                    ContactEMail  = model.ContactEMail,
                    ContactMobile = model.ContactMobile,
                    ContactPhone  = model.ContactPhone,
                    Name          = model.Name,
                    PickupAddress = model.PickupAddress,
                    PostCode      = model.PostCode
                };
                CarSalesDBEntities db = new CarSalesDBEntities();
                db.Sellers.Add(seller);
                db.SaveChanges();

                return(RedirectToAction("SellerRegisterDetail", "Account", new { ID = seller.ID }));
            }

            var result = await UserManager.PasswordValidator.ValidateAsync(model.Password);

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", result.Errors.FirstOrDefault());
                return(View(model));
            }

            var user = new IdentityUser(model.ContactEMail)
            {
                Email = model.ContactEMail
            };
            var identityResult = await UserManager.CreateAsync(user, model.Password);

            if (identityResult.Succeeded)
            {
                Seller seller = new Seller()
                {
                    AspNetUsersId = user.Id,
                    ContactEMail  = model.ContactEMail, ContactMobile = model.ContactMobile, ContactPhone = model.ContactPhone,
                    Name          = model.Name, PickupAddress = model.PickupAddress, PostCode = model.PostCode
                };
                CarSalesDBEntities db = new CarSalesDBEntities();
                db.Sellers.Add(seller);
                db.SaveChanges();
                var signInStatus = SignInManager.PasswordSignIn(user.Email, model.Password, true, true);

                return(RedirectToAction("SellerRegisterDetail", "Account", new { ID = seller.ID }));
            }

            ModelState.AddModelError("", identityResult.Errors.FirstOrDefault());

            return(View(model));
        }
Exemplo n.º 10
0
        public IHttpActionResult PutVehicleModel(int id, CarSalesVehicleModel carSalesVehicleModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carSalesVehicleModel.ID)
            {
                return(BadRequest());
            }

            VehicleModel vehicleModel = new VehicleModel()
            {
                ID            = carSalesVehicleModel.ID,
                VehicleMakeID = carSalesVehicleModel.VehicleMakeID,
                VehicleModel1 = carSalesVehicleModel.VehicleModel1
            };


            db.Entry(vehicleModel).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VehicleModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutVehicleBody(int id, CarSalesVehicleBody carSalesVehicleBody)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carSalesVehicleBody.ID)
            {
                return(BadRequest());
            }

            VehicleBody vehicleBody = new VehicleBody()
            {
                ID = carSalesVehicleBody.ID,
                BodyDescription = carSalesVehicleBody.BodyDescription,
                ImageURL        = carSalesVehicleBody.ImageURL
            };

            db.Entry(vehicleBody).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VehicleBodyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 12
0
        public IHttpActionResult PutViewPortSetting(int id, CarSalesViewPortSetting carSalesViewPortSetting)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carSalesViewPortSetting.ID)
            {
                return(BadRequest());
            }
            ViewPortSetting ViewPortSetting = new ViewPortSetting();

            ViewPortSetting.ID          = carSalesViewPortSetting.ID;
            ViewPortSetting.PageSize    = carSalesViewPortSetting.PageSize;
            ViewPortSetting.SettingCode = carSalesViewPortSetting.SettingCode;
            ViewPortSetting.ViewPortID  = carSalesViewPortSetting.ViewPortID;

            db.Entry(ViewPortSetting).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ViewPortSettingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 13
0
        public IHttpActionResult PutConfigSetting(int id, CarSalesConfigSetting carSalesConfigSetting)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carSalesConfigSetting.ID)
            {
                return(BadRequest());
            }
            ConfigSetting configSetting = new ConfigSetting();

            configSetting.ID = carSalesConfigSetting.ID;
            configSetting.VehicleAdvertisementNextRefNo = carSalesConfigSetting.VehicleAdvertisementNextRefNo;

            db.Entry(configSetting).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ConfigSettingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 14
0
        public HttpResponseMessage Post([FromBody] ApiSalesperson newSalesperson)
        {
            if (ModelState.IsValid)
            {
                Salesperson c = new Salesperson();
                PropertyCopier <ApiSalesperson, Salesperson> .Copy(newSalesperson, c);

                db.Salespersons.Add(c);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                       "Cannot add new Salesperson, Try again." + e.StackTrace + "---" + e.InnerException));
                }
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, "Salesperson added."));
        }
Exemplo n.º 15
0
        public IHttpActionResult PutViewPort(int id, CarSalesViewPort carSalesViewPort)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carSalesViewPort.ID)
            {
                return(BadRequest());
            }
            ViewPort ViewPort = new ViewPort();

            ViewPort.ID          = carSalesViewPort.ID;
            ViewPort.Description = carSalesViewPort.Description;

            db.Entry(ViewPort).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ViewPortExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 16
0
        // GET: VehicleAdvertisementsMVC/Create
        public ActionResult Edit(int?Reference_ID = 0)
        {
            ViewBag.Src     = "";
            ViewBag.Message = "";
            CarSalesVehicleAdvertisement CarSalesVehicleAdvertisement;
            CarSalesDBEntities           db = new CarSalesDBEntities();
            VehicleAdvertisement         vehicleAdvertisement = db.VehicleAdvertisements.Find(Reference_ID);

            if (Reference_ID != 0)
            {
                CarSalesVehicleAdvertisement = new CarSalesVehicleAdvertisement()
                {
                    Archived       = vehicleAdvertisement.Archived,
                    AudoMeter      = vehicleAdvertisement.AudoMeter,
                    BodyType       = vehicleAdvertisement.BodyType,
                    DateAdvertised = vehicleAdvertisement.DateAdvertised,
                    Description    = vehicleAdvertisement.Description,
                    EngineCapacity = vehicleAdvertisement.EngineCapacity,
                    Feature        = vehicleAdvertisement.Feature,
                    Fuel           = vehicleAdvertisement.Fuel,
                    IsFeatured     = vehicleAdvertisement.IsFeatured,
                    Make           = vehicleAdvertisement.Make,
                    Model          = vehicleAdvertisement.Model,
                    Price          = vehicleAdvertisement.Price,
                    Reference_ID   = vehicleAdvertisement.Reference_ID,
                    Reference_No   = vehicleAdvertisement.Reference_No,
                    Sold           = vehicleAdvertisement.Sold,
                    Spects         = vehicleAdvertisement.Spects,
                    Title          = vehicleAdvertisement.Title,
                    Transmission   = vehicleAdvertisement.Transmission
                };
            }
            else
            {
                var ConfigSettings = db.ConfigSettings.FirstOrDefault();
                CarSalesVehicleAdvertisement = new CarSalesVehicleAdvertisement()
                {
                    Reference_No = ConfigSettings.VehicleAdvertisementNextRefNo.Value.ToString("00000")
                };
                ConfigSettings.VehicleAdvertisementNextRefNo = ConfigSettings.VehicleAdvertisementNextRefNo + 1;
                db.SaveChanges();
            }
            return(View(CarSalesVehicleAdvertisement));
        }
        public ActionResult SellerRegisterEdit(SellerRegisterModel SellerRegisterModel)
        {
            CarSalesDBEntities db     = new CarSalesDBEntities();
            Seller             seller = db.Sellers.Find(SellerRegisterModel.ID);

            if (seller == null)
            {
                return(HttpNotFound());
            }
            else
            {
                seller.Name            = SellerRegisterModel.Name;
                seller.ContactEMail    = SellerRegisterModel.ContactEMail;
                seller.ContactMobile   = SellerRegisterModel.ContactMobile;
                seller.ContactPhone    = SellerRegisterModel.ContactPhone;
                seller.PickupAddress   = SellerRegisterModel.PickupAddress;
                seller.PostCode        = SellerRegisterModel.PostCode;
                db.Entry(seller).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("SellerRegisterDetail", "Account", new { ID = seller.ID }));
            }
        }
Exemplo n.º 18
0
        public ActionResult Edit(CarSalesVehicleAdvertisement CarSalesVehicleAdvertisement, HttpPostedFileBase postedFile)
        {
            CarSalesDBEntities db = new CarSalesDBEntities();

            if (ModelState.IsValid)
            {
                int SellerID = CarSales.API.Helper.HelperClass.GetSeller(System.Web.HttpContext.Current.User.Identity.Name).ID;

                VehicleAdvertisement VehicleAdvertisement = db.VehicleAdvertisements.Find(CarSalesVehicleAdvertisement.Reference_ID);
                if (VehicleAdvertisement == null)
                {
                    VehicleAdvertisement = new VehicleAdvertisement();
                }

                VehicleAdvertisement.Archived       = CarSalesVehicleAdvertisement.Archived;
                VehicleAdvertisement.AudoMeter      = CarSalesVehicleAdvertisement.AudoMeter;
                VehicleAdvertisement.BodyType       = CarSalesVehicleAdvertisement.BodyType;
                VehicleAdvertisement.DateAdvertised = CarSalesVehicleAdvertisement.DateAdvertised;
                VehicleAdvertisement.Description    = CarSalesVehicleAdvertisement.Description;
                VehicleAdvertisement.EngineCapacity = CarSalesVehicleAdvertisement.EngineCapacity;
                VehicleAdvertisement.Feature        = CarSalesVehicleAdvertisement.Feature;
                VehicleAdvertisement.Fuel           = CarSalesVehicleAdvertisement.Fuel;
                VehicleAdvertisement.IsFeatured     = CarSalesVehicleAdvertisement.IsFeatured;
                VehicleAdvertisement.Make           = CarSalesVehicleAdvertisement.Make;
                VehicleAdvertisement.Model          = CarSalesVehicleAdvertisement.Model;
                VehicleAdvertisement.Price          = CarSalesVehicleAdvertisement.Price;
                VehicleAdvertisement.Reference_ID   = CarSalesVehicleAdvertisement.Reference_ID;
                VehicleAdvertisement.Reference_No   = CarSalesVehicleAdvertisement.Reference_No;
                VehicleAdvertisement.Sold           = CarSalesVehicleAdvertisement.Sold;
                VehicleAdvertisement.Spects         = CarSalesVehicleAdvertisement.Spects;
                VehicleAdvertisement.Title          = CarSalesVehicleAdvertisement.Title;
                VehicleAdvertisement.Transmission   = CarSalesVehicleAdvertisement.Transmission;

                if (CarSalesVehicleAdvertisement.Reference_ID == 0)
                {
                    db.VehicleAdvertisements.Add(VehicleAdvertisement);
                    db.SaveChanges();
                    var VehicleSeller = new VehicleSeller()
                    {
                        SellerID = SellerID,


                        VehicleID = VehicleAdvertisement.Reference_ID,
                    };
                    db.VehicleSellers.Add(VehicleSeller);
                    db.SaveChanges();
                }
                else
                {
                    db.SaveChanges();
                }

                if (postedFile != null)
                {
                    string path = Server.MapPath("~/Uploads/");
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    postedFile.SaveAs(path + CarSalesVehicleAdvertisement.Reference_No + ".jpg");
                }


                return(RedirectToAction("SellerRegisterDetail", "Account", new { ID = SellerID }));
            }

            return(View(CarSalesVehicleAdvertisement));
        }