public bool UpdateAuctionHouseCarSelling(AuctionHouseCarSelling auctionHouseCarSelling)
 {
     if (auctionHouseCarSelling == null)
         return false;
     else
     {
         _auctionHouseCarSellingRepository.Update(auctionHouseCarSelling);
         return true;
     }
 }
 public AuctionHouseCarSelling InsertAuctionHouseCarSelling(AuctionHouseCarSelling auctionHouseCarSelling)
 {
     if (auctionHouseCarSelling == null)
         return null;
     else
     {
         _auctionHouseCarSellingRepository.Insert(auctionHouseCarSelling);
         return auctionHouseCarSelling;
     }
 }
        public void DeleteAuctionHouseCarSelling(AuctionHouseCarSelling auctionHouseCarSelling)
        {
            if (auctionHouseCarSelling == null)
                throw new ArgumentNullException("auctionHouseCarSelling");
            else
            {
                AuctionHouseCarSelling result = _auctionHouseCarSellingRepository.GetById(auctionHouseCarSelling.AuctionHouseCarSellingID);

                _auctionHouseCarSellingRepository.Delete(result);

            }
        }
        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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);

            }
        }