Пример #1
0
        public ActionResult CarSellingRegistration(CarSellerVehicleInfoModel model)
        {
            if (Session["CarSellerInfoID"] != null)
            {
                int newMakeID = 0;
                int newCarModelID = 0;

                var getMakeDetails = _makeService.GetMakeByName(model.NewCarMakeName);
                if (getMakeDetails == null)
                {
                    Make objMake = new Make();
                    objMake.Makename = model.NewCarMakeName;
                    objMake.IsRemoved = false;
                    _makeService.InsertMake(objMake);
                    if (objMake.ID > 0)
                        newMakeID = objMake.ID;
                }
                else
                {
                    newMakeID = getMakeDetails.ID;
                }

                var getModelDetails = _carModelService.GetCarModelByName(model.NewCarModelName);
                if (getModelDetails == null)
                {
                    CarModel objCarModel = new CarModel();
                    objCarModel.Modelname = model.NewCarModelName;
                    objCarModel.MakeID = newMakeID;
                    _carModelService.InsertCarModel(objCarModel);
                    if (objCarModel.ID > 0)
                        newCarModelID = objCarModel.ID;
                }
                else
                {
                    newCarModelID = getModelDetails.ID;
                }

                if (Session["VehicleID"] == null)
                {
                    CarSellerVehicleInfo obj = new CarSellerVehicleInfo();
                    obj.CarSellerInfoID = Convert.ToInt32(Session["CarSellerInfoID"]);
                    obj.RegistrationNumber = model.RegistrationNumber;
                    obj.Title = model.Title;
                    obj.MakeID = newMakeID;
                    obj.ModelID = newCarModelID;
                    obj.BodyTypeID = model.BodyTypeID;
                    obj.Color = model.Color;
                    obj.EngineSize = model.EngineSize;
                    if (!string.IsNullOrEmpty(model.MOTExpiryDate))
                        obj.MOTExpiryDate = DateTime.ParseExact(model.MOTExpiryDate, "dd/MM/yyyy", null);
                    obj.TransmissionTypeID = model.TransmissionTypeID;
                    obj.ExactMileage = model.ExactMileage;
                    obj.InteriorColor = model.InteriorColor;
                    obj.Trim = model.Trim;
                    if (!string.IsNullOrEmpty(model.TAXExpiryDate))
                        obj.TAXExpiryDate = DateTime.ParseExact(model.TAXExpiryDate, "dd/MM/yyyy", null);
                    obj.ServiceHistory = model.ServiceHistory;
                    obj.Description = model.Description;
                    if (!string.IsNullOrEmpty(model.DateOfFirstRegistration))
                        obj.DateOfFirstRegistration = DateTime.ParseExact(model.DateOfFirstRegistration, "dd/MM/yyyy", null);
                    obj.AddedDate = DateTime.Now;
                    _carSellerVehicleInfoService.InsertCarSellerVehicleInfo(obj);
                    Session["VehicleID"] = obj.ID;
                    model.ID = Convert.ToInt32(Session["VehicleID"]);

                    //model.ID = obj.ID;
                }
                else
                {

                    CarSellerVehicleInfo objCarSellerVehicleInfo = _carSellerVehicleInfoService.GetCarSellerVehicleInfoByID(Convert.ToInt32(Session["VehicleID"]));
                    if (objCarSellerVehicleInfo != null)
                    {
                        objCarSellerVehicleInfo.CarSellerInfoID = Convert.ToInt32(Session["CarSellerInfoID"]);
                        objCarSellerVehicleInfo.RegistrationNumber = model.RegistrationNumber;
                        objCarSellerVehicleInfo.Title = model.Title;
                        objCarSellerVehicleInfo.MakeID = newMakeID;
                        objCarSellerVehicleInfo.ModelID = newCarModelID;
                        objCarSellerVehicleInfo.BodyTypeID = model.BodyTypeID;
                        objCarSellerVehicleInfo.Color = model.Color;
                        objCarSellerVehicleInfo.EngineSize = model.EngineSize;
                        if (!string.IsNullOrEmpty(model.MOTExpiryDate))
                            objCarSellerVehicleInfo.MOTExpiryDate = DateTime.ParseExact(model.MOTExpiryDate, "dd/MM/yyyy", null);
                        objCarSellerVehicleInfo.TransmissionTypeID = model.TransmissionTypeID;
                        objCarSellerVehicleInfo.ExactMileage = model.ExactMileage;
                        objCarSellerVehicleInfo.InteriorColor = model.InteriorColor;
                        objCarSellerVehicleInfo.Trim = model.Trim;
                        if (!string.IsNullOrEmpty(model.TAXExpiryDate))
                            objCarSellerVehicleInfo.TAXExpiryDate = DateTime.ParseExact(model.TAXExpiryDate, "dd/MM/yyyy", null);
                        objCarSellerVehicleInfo.ServiceHistory = model.ServiceHistory;
                        objCarSellerVehicleInfo.Description = model.Description;
                        if (!string.IsNullOrEmpty(model.DateOfFirstRegistration))
                            objCarSellerVehicleInfo.DateOfFirstRegistration = DateTime.ParseExact(model.DateOfFirstRegistration, "dd/MM/yyyy", null);
                        _carSellerVehicleInfoService.UpdateCarSellerVehicleInfo(objCarSellerVehicleInfo);

                        model.ID = Convert.ToInt32(Session["VehicleID"]);

                        //model.ID = objCarSellerVehicleInfo.ID;

                        List<CarSellerVehicleFuelType> carSellerVehicleFuelType = _carSellerVehicleFuelTypeService.CarSellerVehicleFuelTypeByVehicleID(Convert.ToInt32(Session["VehicleID"]));
                        _carSellerVehicleFuelTypeService.DeleteCarSellerVehicleFuelType(carSellerVehicleFuelType);
                    }
                    else
                    {
                        return Json(false, JsonRequestBehavior.AllowGet);
                    }

                }
                if (Convert.ToInt32(Session["VehicleID"]) > 0)
                {
                    foreach (var item in model.FuelTypeList)
                    {
                        if (item.IsChecked)
                        {
                            CarSellerVehicleFuelType objCarSellerVehicleFuelType = new CarSellerVehicleFuelType();
                            objCarSellerVehicleFuelType.VehicleID = Convert.ToInt32(Session["VehicleID"]);
                            objCarSellerVehicleFuelType.FuelTypeID = Convert.ToInt32(item.ID);
                            _carSellerVehicleFuelTypeService.InsertCarSellerVehicleFuelType(objCarSellerVehicleFuelType);

                        }
                    }
                    return Json(true, JsonRequestBehavior.AllowGet);
                }
                else

                    return Json(false, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(false, JsonRequestBehavior.AllowGet);
            }
        }
Пример #2
0
        public ActionResult GetModels(long makeID)
        {
            List<CarSellerVehicleInfoModel> list = new List<CarSellerVehicleInfoModel>();
            var carModelList = _carModelService.GetAllCarModels().Where<CarModel>(cm => cm.MakeID == makeID).ToList<CarModel>();
            if (carModelList != null)
            {

                foreach (CarModel item in carModelList)
                {
                    CarSellerVehicleInfoModel model = new CarSellerVehicleInfoModel();
                    model.ModelID = item.ID;
                    model.ModelName = item.Modelname;

                    list.Add(model);

                }
                return Json(list, JsonRequestBehavior.AllowGet);
            }

            else
                return Json(null, JsonRequestBehavior.AllowGet);
        }
Пример #3
0
        public ActionResult PrivateSellerVehicleInfo(long Id = 0)
        {
            string UserName = Request.RequestContext.HttpContext.User.Identity.Name;
            var UserDetails = _aspNetUserService.GetAspNetUserByUserName(UserName);
            long id = UserDetails.AspNetUsersAdditionalInfoes.FirstOrDefault().ID;

            CarSellerVehicleInfoModel model = new CarSellerVehicleInfoModel();
            var MyCarList = _carSellerVehicleInfoService.GetAllCarSellerVehicleInfo().Where(vi => vi.CarSellerInfo.UserID == id).OrderByDescending(m => m.AddedDate).Take(2).ToList();
            model.CarSellerVehicleInfoList = MyCarList;
            if (Id != 0)
            {
                Session["VehicleID"] = Id;

                var carSellerVehiclesDetails = _carSellerVehicleInfoService.GetCarSellerVehicleInfoByID(Id);
                if (carSellerVehiclesDetails != null)
                {
                    Session["CarSellerInfoID"] = carSellerVehiclesDetails.CarSellerInfoID;
                    model.RegistrationNumber = carSellerVehiclesDetails.RegistrationNumber;
                    model.Title = carSellerVehiclesDetails.Title;
                    model.ExactMileage = carSellerVehiclesDetails.ExactMileage;
                    model.BodyTypeID = Convert.ToInt32(carSellerVehiclesDetails.BodyTypeID);
                    model.MakeID = Convert.ToInt32(carSellerVehiclesDetails.MakeID);
                    model.ModelID = Convert.ToInt32(carSellerVehiclesDetails.ModelID);
                    model.TransmissionTypeID = Convert.ToInt32(carSellerVehiclesDetails.TransmissionTypeID);
                    model.Color = carSellerVehiclesDetails.Color;
                    model.EngineSize = carSellerVehiclesDetails.EngineSize;
                    model.Price = carSellerVehiclesDetails.Price.ToString();
                    model.DateOfFirstRegistration = Convert.ToDateTime(carSellerVehiclesDetails.DateOfFirstRegistration).ToString("dd/MM/yyyy");
                    model.EngineSize = carSellerVehiclesDetails.EngineSize;
                    model.CarSellerVehicleImageList = _carSellerVehicleImagesService.GetCarSellerVehicleImageByVehicleID(Id);
                    var fuelTypeList = _fuelTypeService.GetAllFuelTypes();
                    if (fuelTypeList != null)
                    {

                        foreach (var item in fuelTypeList)
                        {

                            if (carSellerVehiclesDetails.CarSellerVehicleFuelTypes.Where(a => a.FuelTypeID == item.ID).Count() > 0)
                            {
                                model.FuelTypeList.Add(new CheckBoxClass
                                {
                                    ID = Convert.ToString(item.ID),
                                    Name = item.Type,
                                    IsChecked = true

                                });
                            }
                            else
                            {
                                model.FuelTypeList.Add(new CheckBoxClass
                                {
                                    ID = Convert.ToString(item.ID),
                                    Name = item.Type,
                                    IsChecked = false

                                });
                            }
                        }

                    }
                }
            }
            else
            {
                if (TempData["regis"] != null)
                    model.RegistrationNumber = TempData["regis"].ToString();
                if (TempData["milage"] != null)
                    model.ExactMileage = TempData["milage"].ToString();
                var fuelTypeList = _fuelTypeService.GetAllFuelTypes();
                if (fuelTypeList != null)
                {

                    foreach (var item in fuelTypeList)
                    {

                        model.FuelTypeList.Add(new CheckBoxClass
                        {
                            ID = Convert.ToString(item.ID),
                            Name = item.Type,
                            IsChecked = false

                        });

                    }
                }
            }
            var bodyTypeList = _bodyTypeService.GetAllBodyTypes();
            if (bodyTypeList != null)
            {
                foreach (var item in bodyTypeList)
                {
                    model.BodyTypeList.Add(new BodyType
                    {
                        ID = item.ID,
                        Type = item.Type
                    });
                }
            }

            var makeList = _makeService.GetAllMakes();

            if (makeList != null)
            {
                foreach (var item in makeList)
                {
                    model.MakeList.Add(new Make
                    {
                        ID = item.ID,
                        Makename = item.Makename
                    });
                }
            }

            var transmissionTypeList = _transmissionTypeService.GetAllTransmissionTypes();
            if (transmissionTypeList != null)
            {
                foreach (var item in transmissionTypeList)
                {
                    model.TransmissionTypeList.Add(new TransmissionType
                    {
                        ID = item.ID,
                        Type = item.Type
                    });
                }
            }

            return View(model);
        }
Пример #4
0
        public ActionResult CarSellingRegistrationDetails(CarSellerVehicleInfoModel model)
        {
            if (Session["VehicleID"] != null)
            {
                long ID = Convert.ToInt64(Session["VehicleID"]);
                if (ID > 0)
                {
                    var carSellerVehicleInfoDetails = _carSellerVehicleInfoService.GetCarSellerVehicleInfoByID(ID);
                    if (carSellerVehicleInfoDetails != null)
                    {

                        decimal? price = (decimal)Decimal.Parse(model.Price.Replace("£", "").Replace(",", ""), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture);
                        carSellerVehicleInfoDetails.Price = price;
                        _carSellerVehicleInfoService.UpdateCarSellerVehicleInfo(carSellerVehicleInfoDetails);
                        int? carSellerType = _carSellerInfoService.GetCarSellerInfoByCarSellerInfoID(carSellerVehicleInfoDetails.CarSellerInfoID).SellerTypeID;
                        if (carSellerType != null)
                        {
                            if (carSellerType != 1)
                            {
                                CarSellerMoreDetail objCarSellerMoreDetail = new CarSellerMoreDetail();
                                objCarSellerMoreDetail.VehicleID = Convert.ToInt32(ID);

                                var CarSellerMoreDetails = _carSellerMoreDetailService.GetCarSellerMoreDetailByVehicleID(ID);
                                if (CarSellerMoreDetails != null)
                                {

                                    CarSellerMoreDetails.CarLocation = model.CarLocation;
                                    CarSellerMoreDetails.ContactEmailID = model.ContactEmailID;
                                    CarSellerMoreDetails.ContactNumber = model.ContactNumber;
                                    CarSellerMoreDetails.ContactNumberOnAdvert = model.ContactNumberOnAdvert;
                                    CarSellerMoreDetails.SelectedPackageID = 1;
                                    _carSellerMoreDetailService.UpdateCarSellerMoreDetail(CarSellerMoreDetails);
                                }
                                else
                                {
                                    objCarSellerMoreDetail.CarLocation = model.CarLocation;
                                    objCarSellerMoreDetail.ContactEmailID = model.ContactEmailID;
                                    objCarSellerMoreDetail.ContactNumber = model.ContactNumber;
                                    objCarSellerMoreDetail.ContactNumberOnAdvert = model.ContactNumberOnAdvert;
                                    objCarSellerMoreDetail.SelectedPackageID = 1;
                                    _carSellerMoreDetailService.InsertCarSellerMoreDetail(objCarSellerMoreDetail);
                                }
                                if (objCarSellerMoreDetail.ID > 0)
                                {
                                    return Json(true, JsonRequestBehavior.AllowGet);
                                }
                                else
                                    return Json(false, JsonRequestBehavior.AllowGet);
                            }
                            else
                            {
                                //Session["VehicleID"] = null;
                                return Json(true, JsonRequestBehavior.AllowGet);
                            }
                        }
                        else
                        {
                            return Json(false, JsonRequestBehavior.AllowGet);
                        }

                    }
                    return Json(false, JsonRequestBehavior.AllowGet);
                }
                else
                    return Json(false, JsonRequestBehavior.AllowGet);
            }
            else
                return Json(false, JsonRequestBehavior.AllowGet);
        }