public void UpdateCarSellerVehicleInfo(CarSellerVehicleInfo carSellerVehicleInfo)
        {
            if (carSellerVehicleInfo == null)
                throw new ArgumentNullException("carSellerVehicleInfo");
            else
            {
                CarSellerVehicleInfo result = _carSellerVehicleInfoRepository.GetById(carSellerVehicleInfo.ID);
                result.IsSendToAuction = carSellerVehicleInfo.IsSendToAuction;
                _carSellerVehicleInfoRepository.Update(result);

            }
        }
        public void DeleteCarSellerVehicleInfo(CarSellerVehicleInfo carSellerVehicleInfo)
        {
            if (carSellerVehicleInfo == null)
                throw new ArgumentNullException("carSellerVehicleInfo");
            else
            {
                CarSellerVehicleInfo result = _carSellerVehicleInfoRepository.GetById(carSellerVehicleInfo.ID);

                _carSellerVehicleInfoRepository.Delete(result);

            }
        }
Example #3
0
        public ActionResult AddToAuction(AddToAuction addToAuction)
        {
            int _id = Convert.ToInt32(addToAuction.VehicleID);
            var varCarDetails = _carsellervehicleinfoService.GetCarSellerVehicleInfo().Where(t => t.ID == _id).FirstOrDefault();

            AuctionHouseCarSelling objAuctionHouseCarSelling = new AuctionHouseCarSelling();
            if (varCarDetails != null)
            {

                objAuctionHouseCarSelling.MakeID = varCarDetails.MakeID;
                objAuctionHouseCarSelling.ModelID = varCarDetails.ModelID;
                objAuctionHouseCarSelling.RegistrationNo = varCarDetails.RegistrationNumber;
                objAuctionHouseCarSelling.Reserve = varCarDetails.Price.ToString();
                objAuctionHouseCarSelling.AuctionHouseID = Convert.ToInt64(addToAuction.AuctionHouseID);
                objAuctionHouseCarSelling.AuctionHouseSaleID = Convert.ToInt64(addToAuction.AuctionHouseSaleID);
                objAuctionHouseCarSelling.VehicleID = varCarDetails.ID;
                objAuctionHouseCarSelling.BodyID = varCarDetails.BodyTypeID;
                objAuctionHouseCarSelling.EngineSize = varCarDetails.EngineSize;
                objAuctionHouseCarSelling.ExactMileage = varCarDetails.ExactMileage;
                objAuctionHouseCarSelling.ExteriorInteriorColour = varCarDetails.Color;
                objAuctionHouseCarSelling.TransmissionTypeIDs = varCarDetails.TransmissionTypeID.ToString();
                objAuctionHouseCarSelling.MOTExpiryDate = varCarDetails.MOTExpiryDate;
                objAuctionHouseCarSelling.TaxExpiryDate = varCarDetails.TAXExpiryDate;
                objAuctionHouseCarSelling.RegistrationDate = varCarDetails.DateOfFirstRegistration;
                objAuctionHouseCarSelling.LastServiceDetails = varCarDetails.ServiceHistory;

                var CarSellerFuelTypes = _carSellerVehicleFuelTypeService.CarSellerVehicleFuelTypeByVehicleID(varCarDetails.ID);

                string strFuelType = "";
                if (CarSellerFuelTypes.Count > 0)
                {
                    foreach (var item in CarSellerFuelTypes)
                    {
                        strFuelType += item.FuelTypeID.ToString()+",";
                    }
                    objAuctionHouseCarSelling.FuelTypeIDs = strFuelType.Trim(',');

                }

                var CarSellerImages = _carsellervehicleimageService.GetCarSellerVehicleImageByVehicleID(varCarDetails.ID).ToList();

                _auctionHouseAddEditVehicleService.InsertAuctionHouseCarSelling(objAuctionHouseCarSelling);

                 CarBuyerInfoModel model = new CarBuyerInfoModel();
                    model.AuctionHouseCarSellingID = objAuctionHouseCarSelling.AuctionHouseCarSellingID;
                if (objAuctionHouseCarSelling.AuctionHouseCarSellingID > 0)
                {
                    if (CarSellerImages != null)
                    {
                        var aucHouseVehicleImage = _auctionHouseCarSellingVehicleImagesService.GetAuctionHouseCarSellingVehicleImages().Where(t => t.AuctionHouseCarSellingID == objAuctionHouseCarSelling.AuctionHouseCarSellingID).ToList();
                        foreach (var img in CarSellerImages)
                        {

                            if (aucHouseVehicleImage.Count==0)
                            {
                                model.AuctionHouseCarSellingID = objAuctionHouseCarSelling.AuctionHouseCarSellingID;
                                model.Filename = img.Filename;
                                model.Foldername = img.Foldername;
                                model.Size = Convert.ToInt32(img.Size);

                                if (model.AuctionHouseCarSellingID != 0 && model.Filename!=null && model.Foldername!=null)
                                {
                                    AuctionHouseCarSellingVehicleImages objAuctionHouseCarSellingVehicleImage = new AuctionHouseCarSellingVehicleImages();

                                    objAuctionHouseCarSellingVehicleImage.AuctionHouseCarSellingID = model.AuctionHouseCarSellingID;
                                    objAuctionHouseCarSellingVehicleImage.Filename = model.Filename;
                                    objAuctionHouseCarSellingVehicleImage.Foldername = "~/Content/Assets/AuctionHouseSaleVehicleImages/";
                                    objAuctionHouseCarSellingVehicleImage.Size = model.Size;
                                    _auctionHouseCarSellingVehicleImagesService.InsertAuctionHouseCarSellingVehicleImage(objAuctionHouseCarSellingVehicleImage);
                                }

                            }

                        }

                    }

                    CarSellerVehicleInfo objCarSellerVehicleInfo = new CarSellerVehicleInfo();

                    objCarSellerVehicleInfo.ID = varCarDetails.ID;
                    objCarSellerVehicleInfo.IsSendToAuction = true;
                    _carsellervehicleinfoService.UpdateCarSellerVehicleInfo(objCarSellerVehicleInfo);

                }

            }
            return Json(objAuctionHouseCarSelling, JsonRequestBehavior.AllowGet);
        }
Example #4
0
        public ActionResult DeleteFromAuction(DeleteFromAuction deleteFromAuction)
        {
            AuctionHouseCarSelling varAuctionHouseCarSelling = _auctionHouseAddEditVehicleService.GetAuctionHouseCarSelling().Where(t => t.AuctionHouseCarSellingID == deleteFromAuction.AuctionHouseCarSellingID).FirstOrDefault();

            AuctionHouseCarSelling obj = new AuctionHouseCarSelling();
            if (varAuctionHouseCarSelling != null)
            {
                obj.AuctionHouseCarSellingID = varAuctionHouseCarSelling.AuctionHouseCarSellingID;
                if (obj.AuctionHouseCarSellingID > 0)
                {

                    var varAuctionHouseCarSellingVehicleImages = _auctionHouseCarSellingVehicleImagesService.GetAuctionHouseCarSellingVehicleImages().Where(t => t.AuctionHouseCarSellingID == varAuctionHouseCarSelling.AuctionHouseCarSellingID).ToList();

                    foreach (var item in varAuctionHouseCarSellingVehicleImages)
                    {
                        _auctionHouseCarSellingVehicleImagesService.DeleteAuctionHouseCarSellingVehicleImage(item);

                    }
                    _auctionHouseAddEditVehicleService.DeleteAuctionHouseCarSelling(obj);

                    CarSellerVehicleInfo objCarSellerVehicleInfo = new CarSellerVehicleInfo();

                    objCarSellerVehicleInfo.ID = deleteFromAuction.VehicleID;
                    objCarSellerVehicleInfo.IsSendToAuction = false;
                    _carsellervehicleinfoService.UpdateCarSellerVehicleInfo(objCarSellerVehicleInfo);

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

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

            }
        }
Example #5
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);
            }
        }
 public void InsertCarSellerVehicleInfo(CarSellerVehicleInfo carSellerVehicleInfo)
 {
     if (carSellerVehicleInfo == null)
         throw new ArgumentNullException("CarSellerVehicleInfo");
     _carSellerVehicleInfoRepository.Insert(carSellerVehicleInfo);
 }