示例#1
0
 public void InsertMake(Make make)
 {
     if (make == null)
         throw new ArgumentNullException("make");
     _makeRepository.Insert(make);
 }
        public ActionResult Edit(AuctionHouseAddEditVehicleModel model)
        {
            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;
            }
            AuctionHouseCarSelling obj = new AuctionHouseCarSelling();

                string UserName = Request.RequestContext.HttpContext.User.Identity.Name;
                var UserDetails = _aspNetUserService.GetAspNetUserByUserName(UserName);
                long userid = UserDetails.AspNetUsersAdditionalInfoes.FirstOrDefault().ID;
                var AuctionHouseDetails = _auctionHouseService.GetAllAuctionDetails().Where(t => t.UserID == userid).FirstOrDefault();
                obj.AuctionHouseCarSellingID = Convert.ToInt64(model.AuctionHouseVehicleID);

                var varAuctionHouseVehicleDetails = _auctionHouseAddEditVehicleService.GetAuctionHouseCarSellingByID(obj.AuctionHouseCarSellingID);

                if (varAuctionHouseVehicleDetails != null)
                {
                    varAuctionHouseVehicleDetails.AuctionHouseID = AuctionHouseDetails.AuctionHouseID;

                    varAuctionHouseVehicleDetails.RegistrationNo = model.RegistrationNo;
                    varAuctionHouseVehicleDetails.AuctionHouseSaleID = model.SaleID;
                    varAuctionHouseVehicleDetails.Reserve = model.Reserve.ToString();
                    varAuctionHouseVehicleDetails.MakeID = model.MakeID;
                    varAuctionHouseVehicleDetails.ModelID = model.ModelID;
                    varAuctionHouseVehicleDetails.BodyID = model.BodyTypeID;
                    varAuctionHouseVehicleDetails.ExteriorInteriorColour = model.ExtIntColor ?? "";
                    if (!string.IsNullOrEmpty(model.MOTExpiryDate))
                        varAuctionHouseVehicleDetails.MOTExpiryDate = DateTime.ParseExact(model.MOTExpiryDate, "dd/MM/yyyy", null);
                    //varAuctionHouseVehicleDetails.EngineSizeID = model.EngineSizeID;
                    varAuctionHouseVehicleDetails.EngineSize = model.EngineSize;
                    varAuctionHouseVehicleDetails.ExactMileage = model.ExactMileage ?? "";
                    varAuctionHouseVehicleDetails.VINNumber = model.VINnumber ?? "";
                    varAuctionHouseVehicleDetails.FormerKeepersDetails = model.FormerKeepersDetails ?? "";
                    varAuctionHouseVehicleDetails.VSDetails = model.VSDetails ?? "";
                    varAuctionHouseVehicleDetails.VCARDetails = model.VCARDetails ?? "";
                    //if (!string.IsNullOrEmpty(model.TAXExpiryDate))
                    //    varAuctionHouseVehicleDetails.TaxExpiryDate = DateTime.ParseExact(model.TAXExpiryDate, "dd/MM/yyyy", null);

                    if (!string.IsNullOrEmpty(model.RegistrationDate))
                        varAuctionHouseVehicleDetails.RegistrationDate = DateTime.ParseExact(model.RegistrationDate, "dd/MM/yyyy", null);

                    varAuctionHouseVehicleDetails.LastServiceDetails = model.LastServiceDetails ?? "";

                    foreach (var item in model.FuelTypeList)
                    {
                        if (item.Checked)
                        {
                            model.FuelTypeIDs += item.ID + ",";
                        }
                    }

                    varAuctionHouseVehicleDetails.FuelTypeIDs = model.FuelTypeIDs.Trim(',');

                    foreach (var item in model.TransmissionTypeList)
                    {
                        if (item.Checked)
                        {
                            model.TransmissionTypeIDs += item.ID + ",";
                        }
                    }
                    varAuctionHouseVehicleDetails.TransmissionTypeIDs = model.TransmissionTypeIDs.Trim(',');
                    foreach (var item in model.InteriorTrimList)
                    {
                        if (item.Checked)
                        {
                            model.interiorTrimIDs += item.ID + ",";
                        }
                    }
                    varAuctionHouseVehicleDetails.InteriorTrimIDs = model.interiorTrimIDs.Trim(',');
                    foreach (var item in model.ServiceHistoryAuctionList)
                    {
                        if (item.Checked)
                        {
                            model.serviceTypeIDs += item.ID + ",";
                        }
                    }
                    varAuctionHouseVehicleDetails.ServiceHistoryAuctionIDs = model.serviceTypeIDs.Trim(',');

                    if (!string.IsNullOrEmpty(model.DateOfFirstRegistration))
                        varAuctionHouseVehicleDetails.DateOfFirstRegistration = DateTime.ParseExact(model.DateOfFirstRegistration, "dd/MM/yyyy", null);
                    foreach (var item in model.ImportedList)
                    {
                        if (item.Checked)
                        {

                            if (item.ID == "1")
                                model.IsImported = true;
                            if (item.ID == "0")
                                model.IsImported = false;

                        }

                    }

                    foreach (var item in model.VCARregisteredList)
                    {
                        if (item.Checked)
                        {

                            if (item.ID == "1")
                                model.IsVCARregistered = true;
                            if (item.ID == "0")
                                model.IsVCARregistered = false;

                        }

                    }
                    foreach (var item in model.FullVSProvidedList)
                    {
                        if (item.Checked)
                        {

                            if (item.ID == "1")
                                model.IsFullVSProvided = true;
                            if (item.ID == "0")
                                model.IsFullVSProvided = false;

                        }

                    }

                    foreach (var item in model.HPIClearList)
                    {
                        if (item.Checked)
                        {

                            if (item.ID == "1")
                                model.IsHPIClear = true;
                            if (item.ID == "0")
                                model.IsHPIClear = false;

                        }

                    }

                    varAuctionHouseVehicleDetails.IsImported = Convert.ToBoolean(model.IsImported);
                    varAuctionHouseVehicleDetails.IsVCARregistered = model.IsVCARregistered;
                    varAuctionHouseVehicleDetails.IsFullVSProvided = model.IsFullVSProvided;
                    varAuctionHouseVehicleDetails.IsHPIClear = model.IsHPIClear;

                }

                model.ErrMsgType = "success";
                _auctionHouseAddEditVehicleService.UpdateAuctionHouseCarSelling(varAuctionHouseVehicleDetails);

                //var regDetails = _auctionHouseAddEditVehicleService.GetAuctionHouseCarSelling().Where(t => t.RegistrationNo == model.RegistrationNo).FirstOrDefault();
                //if (regDetails != null)
                //{

                //    model.ErrMsg = "This Registration Number already exists...., Enter different one.";
                //    model.ErrMsgType = "duplicate";

                //}
                //else
                //{
                //    // model.ErrMsg = "This Registration Number already exists...., Enter different one.";
                //    model.ErrMsgType = "success";
                //    _auctionHouseAddEditVehicleService.UpdateAuctionHouseCarSelling(varAuctionHouseVehicleDetails);
                //    model.AuctionHouseVehicleID = obj.ID;

                //}

                Session["AuctionHouseVehicleID"] = varAuctionHouseVehicleDetails.AuctionHouseCarSellingID;

            model.AuctionHouseVehicleID = obj.AuctionHouseCarSellingID;
            return Json(model, JsonRequestBehavior.AllowGet);
        }
示例#3
0
        public ActionResult Search(IndexHomeModel model)
        {
            IndexHomeModel objIndexHomeModel = new IndexHomeModel();
            try
            {
                List<CarSellerVehicleInfo> searchList = null;
                decimal minPrice = Convert.ToDecimal(model.minPrice);
                decimal maxPrice = Convert.ToDecimal(model.maxPrice);

                List<CarDetailsModel> carDetailsModelList = new List<CarDetailsModel>();

                List<Make> makeModelList = new List<Make>();
                List<CarModel> carModelList = new List<CarModel>();
                List<BodyType> bodyTypeList = new List<BodyType>();
                List<CarSellerType> carSellerTypeList = new List<CarSellerType>();
                List<TransmissionType> transmissionTypeList = new List<TransmissionType>();
                List<FuelType> fuelTypeList = new List<FuelType>();
                List<CarSellingOn> carSellingOnList = new List<CarSellingOn>();

                //CarDetailsSearchModel obj = new CarDetailsSearchModel();
                //obj.BodyTypeName = model.MakeName;
                //list.Add(obj);
                //list.Add(model.MakeName);
                //list.Add(model.ModelName);
                //list.Add(model.CarSellerTypeName);
                //list.Add(model.BodyTypeName);
                //list.Add(model.TransmissionName);
                //list.Add(model.FuelTypeName);
                //list.Add(model.SearchText);

                List<String> list = new List<String>();
                list.Add(model.MakeName);
                list.Add(model.ModelName);
                list.Add(model.CarSellerTypeName);
                list.Add(model.BodyTypeName);
                list.Add(model.TransmissionName);
                list.Add(model.FuelTypeName);
                list.Add(model.SearchText);

                //ArrayList list = new ArrayList();
                //list.Add(model.MakeName);
                //list.Add(model.ModelName);
                //list.Add(model.CarSellerTypeName);
                //list.Add(model.BodyTypeName);
                //list.Add(model.TransmissionName);
                //list.Add(model.FuelTypeName);

                searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(p => list.Any(p2 => p2.Contains(p.Make.Makename) && p2.Contains(p.Model.Modelname) && p2.Contains(p.BodyType.Type) && p2.Contains(p.TransmissionType.Type) && p2.Contains(p.Price.ToString()))).ToList();

                //searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(p => !list.Contains(p.Make.Makename) && !list.Contains(p.Model.Modelname) && !list.Contains(p.BodyType.ToString()) && !list.Contains(p.TransmissionType.ToString()) && !list.Contains(p.FuelType.ToString()) && !list.Contains(p.Price.ToString())).ToList();

                //searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(p => !list.Contains(p.Make.Makename) && !list.Contains(p.Model.Modelname) && !list.Contains(p.BodyType.ToString()) && !list.Contains(p.TransmissionType.ToString()) && !list.Contains(p.FuelType.ToString()) && !list.Contains(p.Price.ToString())).ToList();

                //if (!(string.IsNullOrEmpty(model.MakeName)))
                //{
                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Make.Makename.Contains(model.MakeName)).ToList();

                //}

                //if (!(string.IsNullOrEmpty(model.ModelName)))
                //{
                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Model.Modelname.Contains(model.ModelName)).ToList();

                //}

                ////if (!(string.IsNullOrEmpty(model.CarSellerTypeName)))
                ////{
                ////    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.CarSellerType.Type.Contains(model.CarSellerTypeName) || u.CarSellerType.Type.Contains(model.SearchText)).ToList();

                ////}

                //if (!(string.IsNullOrEmpty(model.BodyTypeName)))
                //{
                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.BodyType.Type.Contains(model.BodyTypeName)).ToList();

                //}

                //if (!(string.IsNullOrEmpty(model.TransmissionName)))
                //{
                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.TransmissionType.Type.Contains(model.TransmissionName)).ToList();

                //}

                //if (!(string.IsNullOrEmpty(model.FuelTypeName)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.CarSellerVehicleFuelTypes.Any(c => c.FuelType.Type == model.FuelTypeName)).ToList();

                //}

                //if (!(string.IsNullOrEmpty(model.minPrice)))
                //{
                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Price >= minPrice).ToList();

                //}

                //if (!(string.IsNullOrEmpty(model.maxPrice)))
                //{
                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Price <= maxPrice).ToList();

                //}

                //if (!(string.IsNullOrEmpty(model.MakeName)) && (!string.IsNullOrEmpty(model.ModelName)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Make.Makename.Contains(model.MakeName) && u.Model.Modelname.Contains(model.ModelName)).ToList();

                //}

                //if ((!string.IsNullOrEmpty(model.MakeName)) && (!string.IsNullOrEmpty(model.maxPrice)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Make.Makename.Contains(model.MakeName) && (u.Price <= maxPrice)).ToList();
                //}

                //if ((!string.IsNullOrEmpty(model.MakeName)) && (!string.IsNullOrEmpty(model.minPrice)))
                //{
                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Make.Makename.Contains(model.MakeName) && (u.Price >= minPrice)).ToList();
                //}

                //if ((!string.IsNullOrEmpty(model.ModelName)) && (!string.IsNullOrEmpty(model.maxPrice)))
                //{
                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Model.Modelname.Contains(model.ModelName)).ToList();

                //}

                //if ((!string.IsNullOrEmpty(model.ModelName)) && (!string.IsNullOrEmpty(model.minPrice)))
                //{
                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Model.Modelname.Contains(model.ModelName) && (u.Price >= minPrice)).ToList();
                //}

                //if ((!string.IsNullOrEmpty(model.maxPrice)) && (!string.IsNullOrEmpty(model.minPrice)))
                //{
                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Price >= minPrice && u.Price <= maxPrice).ToList();

                //}

                //if ((!string.IsNullOrEmpty(model.MakeName)) && (!string.IsNullOrEmpty(model.ModelName)) && (!string.IsNullOrEmpty(model.minPrice)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Make.Makename.Contains(model.MakeName) && u.Model.Modelname.Contains(model.ModelName) && (u.Price >= minPrice)).ToList();

                //}

                //if ((!string.IsNullOrEmpty(model.MakeName)) && (!string.IsNullOrEmpty(model.ModelName)) && (!string.IsNullOrEmpty(model.maxPrice)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Make.Makename.Contains(model.MakeName) && u.Model.Modelname.Contains(model.ModelName) && (u.Price <= maxPrice)).ToList();

                //}

                //if ((!string.IsNullOrEmpty(model.MakeName)) && (!string.IsNullOrEmpty(model.maxPrice)) && (!string.IsNullOrEmpty(model.minPrice)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Make.Makename.Contains(model.MakeName) && (u.Price <= maxPrice) && (u.Price >= minPrice)).ToList();
                //}

                //if ((!string.IsNullOrEmpty(model.ModelName)) && (!string.IsNullOrEmpty(model.maxPrice)) && (!string.IsNullOrEmpty(model.minPrice)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Model.Modelname.Contains(model.ModelName) && (u.Price <= maxPrice) && (u.Price >= minPrice)).ToList();

                //}
                //if ((!string.IsNullOrEmpty(model.maxPrice)) && (!string.IsNullOrEmpty(model.minPrice)) && (!string.IsNullOrEmpty(model.MakeName)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Make.Makename.Contains(model.MakeName) && (u.Price <= maxPrice) && (u.Price >= minPrice)).ToList();

                //}

                //if ((!string.IsNullOrEmpty(model.maxPrice)) && (!string.IsNullOrEmpty(model.minPrice)) && (!string.IsNullOrEmpty(model.ModelName)))
                //{
                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Model.Modelname.Contains(model.ModelName) && (u.Price <= maxPrice) && (u.Price >= minPrice)).ToList();

                //}

                //if ((!string.IsNullOrEmpty(model.MakeName)) && (!string.IsNullOrEmpty(model.ModelName)) && (!string.IsNullOrEmpty(model.minPrice)) && (!string.IsNullOrEmpty(model.maxPrice)) && (!string.IsNullOrEmpty(model.TransmissionName)) && (!string.IsNullOrEmpty(model.BodyTypeName)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Make.Makename.Contains(model.MakeName) && u.Model.Modelname.Contains(model.ModelName) && (u.Price >= minPrice && u.Price <= maxPrice)  && u.TransmissionType.Type.Contains(model.TransmissionName) && u.BodyType.Type.Contains(model.BodyTypeName) || u.Make.Makename.Contains(model.SearchText) || u.Model.Modelname.Contains(model.SearchText) || u.TransmissionType.Type.Contains(model.SearchText) || u.BodyType.Type.Contains(model.SearchText)).ToList();

                //}

                //if ((!string.IsNullOrEmpty(model.MakeName)) && (!string.IsNullOrEmpty(model.ModelName)) && (!string.IsNullOrEmpty(model.TransmissionName)) && (!string.IsNullOrEmpty(model.BodyTypeName)) && (!string.IsNullOrEmpty(model.FuelTypeName)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Make.Makename.Contains(model.MakeName) && u.Model.Modelname.Contains(model.ModelName) && u.TransmissionType.Type.Contains(model.TransmissionName) && u.BodyType.Type.Contains(model.BodyTypeName) && u.CarSellerVehicleFuelTypes.Any(c=>c.FuelType.Type == model.FuelTypeName) || (u.Make.Makename.Contains(model.SearchText) || u.Model.Modelname.Contains(model.SearchText) || u.TransmissionType.Type.Contains(model.SearchText) || u.BodyType.Type.Contains(model.SearchText) || u.CarSellerVehicleFuelTypes.Any(c => c.FuelType.Type == model.FuelTypeName)) ).ToList();

                //}

                //if ((string.IsNullOrEmpty(model.MakeName)) && (string.IsNullOrEmpty(model.ModelName)) && (string.IsNullOrEmpty(model.minPrice)) && (string.IsNullOrEmpty(model.maxPrice)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetAllCarSellerVehicleInfo().ToList();

                //}

                //if ((string.IsNullOrEmpty(model.MakeName)) && (string.IsNullOrEmpty(model.ModelName)) && (string.IsNullOrEmpty(model.TransmissionName)) && (string.IsNullOrEmpty(model.BodyTypeName)) && (string.IsNullOrEmpty(model.FuelTypeName)) && (!string.IsNullOrEmpty(model.SearchText)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetCarSellerVehicleInfo().Where(u => u.Make.Makename.Contains(model.SearchText) || u.Model.Modelname.Contains(model.SearchText) || u.TransmissionType.Type.Contains(model.SearchText) || u.BodyType.Type.Contains(model.SearchText) || u.CarSellerVehicleFuelTypes.Any(c => c.FuelType.Type == model.FuelTypeName)).ToList();

                //}

                //if ((string.IsNullOrEmpty(model.MakeName)) && (string.IsNullOrEmpty(model.ModelName)) && (string.IsNullOrEmpty(model.TransmissionName)) && (string.IsNullOrEmpty(model.BodyTypeName)) && (string.IsNullOrEmpty(model.FuelTypeName)) && (string.IsNullOrEmpty(model.SearchText)))
                //{

                //    searchList = _carSellerVehicleInfoService.GetAllCarSellerVehicleInfo().ToList();

                //}

                if (searchList != null)
                {

                    foreach (var item in searchList)
                    {
                        if ((item.Title != null) && (item.Price != null || item.Price != 0) && (item.RegistrationNumber != null) && (item.ExactMileage != null))
                        {
                            //var moreinfo = _carSellerMoreDetailService.GetCarSellerMoreDetailByVehicleID(item.ID);
                            //if (moreinfo != null)
                            //{
                                CarDetailsModel carDetails = new CarDetailsModel();

                                carDetails.Title = item.Title;
                                carDetails.MakeName = item.Make.Makename;
                                carDetails.ModelName = item.Model.Modelname;
                                carDetails.Price = Convert.ToDecimal(item.Price);
                                carDetails.RegistrationNo = item.RegistrationNumber;
                                carDetails.ExactMileage = item.ExactMileage;
                                carDetails.TransmissionType = item.TransmissionType.Type;
                                //carDetails.ContactNumber = item.CarSellerMoreDetails.FirstOrDefault().ContactNumber ?? "";
                                //carDetails.Email = item.CarSellerMoreDetails.FirstOrDefault().ContactEmailID ?? "";

                                List<CarSellerVehicleImage> imginfo = _carSellerVehicleImagesService.GetCarSellerVehicleImageByVehicleID(item.ID).ToList();
                                carDetails.CarImages = imginfo;

                            //    carDetails.CarImages = item.CarSellerVehicleImages.ToList();
                                string fuels = "";
                                foreach (var fuelType in item.CarSellerVehicleFuelTypes)
                                {
                                    fuels += fuelType.FuelType.Type + ",";
                                }
                                carDetails.fuelType = fuels.Trim(',');
                                carDetails.Description = item.Description;
                                carDetailsModelList.Add(carDetails);
                            //}

                        }
                    }
                }
                else
                {

                }
                var makelist = _makeService.GetAllMakes();
                if (makelist != null)
                {

                    foreach (var item1 in makelist)
                    {
                        Make obj = new Make();
                        obj.ID = item1.ID;
                        obj.Makename = item1.Makename;
                        makeModelList.Add(obj);

                    }

                }

                var varBodyTypeList = _bodyTypeService.GetAllBodyTypes();
                if (varBodyTypeList != null)
                {
                    foreach (var item in varBodyTypeList)
                    {
                        BodyType obj = new BodyType();
                        obj.ID = item.ID;
                        obj.Type = item.Type;
                        bodyTypeList.Add(obj);

                    }
                }

                var varCarSellerTypeList = _carSellerTyeService.GetAllCarSellerType();
                if (varCarSellerTypeList != null)
                {
                    foreach (var item in varCarSellerTypeList)
                    {
                        CarSellerType obj = new CarSellerType();
                        obj.ID = item.ID;
                        obj.Type = item.Type;
                        carSellerTypeList.Add(obj);

                    }
                }

                var varTransmissionTypeList = _transmissionTyeService.GetAllTransmissionTypes();
                if (varTransmissionTypeList != null)
                {
                    foreach (var item in varTransmissionTypeList)
                    {
                        TransmissionType obj = new TransmissionType();
                        obj.ID = item.ID;
                        obj.Type = item.Type;
                        transmissionTypeList.Add(obj);

                    }
                }

                var varFuelTypeList = _fuelTypeService.GetAllFuelTypes();
                if (varFuelTypeList != null)
                {
                    foreach (var item in varFuelTypeList)
                    {
                        FuelType obj = new FuelType();
                        obj.ID = item.ID;
                        obj.Type = item.Type;
                        fuelTypeList.Add(obj);

                    }
                }

                var varcarSellingOnList = _carSellingOnService.GetAllCarSellinOn();
                if (varcarSellingOnList != null)
                {
                    foreach (var item in varcarSellingOnList)
                    {
                        CarSellingOn obj = new CarSellingOn();
                        obj.ID = item.ID;
                        obj.Way = item.Way;
                        carSellingOnList.Add(obj);

                    }
                }

                var carModelList1 = _carModelService.GetAllCarModels();
                if (carModelList1 != null)
                {
                    foreach (var item in carModelList1)
                    {
                        CarModel obj = new CarModel();
                        obj.ID = item.ID;
                        obj.Modelname = item.Modelname;
                        obj.MakeID = item.MakeID;
                        carModelList.Add(obj);

                    }
                }

                objIndexHomeModel.CarDetailsList = carDetailsModelList;
                objIndexHomeModel.MakeList = makeModelList;
                objIndexHomeModel.bodyTypeList = bodyTypeList;
                objIndexHomeModel.CarSellerTypeList = carSellerTypeList;
                objIndexHomeModel.transmissionTypeList = transmissionTypeList;
                objIndexHomeModel.fuelTypeList = fuelTypeList;
                objIndexHomeModel.CarSellingOnList = carSellingOnList;
                objIndexHomeModel.ModelList = carModelList;

            }
            catch (Exception ex)
            {
                return RedirectToAction("Index", "Home");
            }
            return View(objIndexHomeModel);
        }
示例#4
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);
            }
        }