public void AddnewRecordInVehicleStatus(Int32 iVehicleId, Int32 iShopId, ImportData objImportData) { UserBL objUserBL = null; String strShopId = String.Empty; //Get Vehicle Info object from current vehicle ID VehicleInfoBL objVehicleInfoBL = VehicleInfoBL.getDataId(iVehicleId); if (objVehicleInfoBL != null) { //Create UserBL object from user ID used in Vehicle Info table objUserBL = UserBL.getByActivityId(Convert.ToInt32(objVehicleInfoBL.iUserId)); strShopId = Convert.ToString(iShopId); } if (objUserBL != null && objVehicleInfoBL != null && !String.IsNullOrEmpty(strShopId)) { SaveVehicleStatus(objVehicleInfoBL, objImportData, objUserBL, strShopId); UserVehicleStatusBL objUserVehicleStatusBL = UserVehicleStatusBL.getDataByVehicleId(iVehicleId); if (objUserVehicleStatusBL != null) { MarketingUsers objMarUser = MarketingUsers.getDataByShopUserAndVehicleId(iShopId, Convert.ToInt32(objVehicleInfoBL.iUserId), iVehicleId); objMarUser.bisShowInProcess = true; objMarUser.Save(); } } else { return; } }
public void SaveMarketingUser(VehicleInfoBL objVehicleInfo, UserBL objUser, String strShopId) { MarketingUsers objMarUser = new MarketingUsers(); objMarUser.iShopId = Convert.ToInt32(strShopId); objMarUser.iUserId = objUser.ID; objMarUser.iVehicleId = objVehicleInfo.ID; objMarUser.bisShowInProcess = true; objMarUser.iVehicleId = objVehicleInfo.ID; objMarUser.Save(); }
public void SaveVehicleStatus(VehicleInfoBL objVehicleInfo, ImportData objImportData, UserBL objUser, String strShopId) { String strStatus = String.Empty; VehicleStatusBL objTemp = null; Boolean bIsStatusChanged = false; int iVehicleStatusId = 0; UserVehicleStatusBL objCustomerVehicleStatus = new UserVehicleStatusBL(); DateTime dtOut; objCustomerVehicleStatus.iUserId = objUser.ID; objCustomerVehicleStatus.iVehicleId = objVehicleInfo.ID; objCustomerVehicleStatus.dtDateIn = DateTime.TryParse(objImportData.Scheduled_In_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null; objCustomerVehicleStatus.dtDateOut = DateTime.TryParse(objImportData.Target_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null; objCustomerVehicleStatus.dtActual_Delivery_Date = DateTime.TryParse(objImportData.Actual_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null; objCustomerVehicleStatus.dtFile_Import_Date = DateTime.TryParse(objImportData.File_Import_date, out dtOut) ? dtOut : (Nullable <DateTime>)null; objCustomerVehicleStatus.dtFile_Import_Time = DateTime.TryParse(objImportData.File_Import_Time, out dtOut) ? dtOut : (Nullable <DateTime>)null; objCustomerVehicleStatus.dtRepair_Start_Date = DateTime.TryParse(objImportData.Repair_Start_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null; objCustomerVehicleStatus.dtDeliveryDate = DateTime.TryParse(objImportData.Actual_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null; objCustomerVehicleStatus.iETA_Hours = Convert.ToInt32(objImportData.ETA_Hours); objCustomerVehicleStatus.iRO_Hours = Convert.ToInt32(objImportData.RO_Hours); objCustomerVehicleStatus.strFile_Status = objImportData.File_Status; System.Collections.Generic.List <SummitShopApp.BL.VehicleStatusBL> lstVehicleStatus = new List <SummitShopApp.BL.VehicleStatusBL>(); lstVehicleStatus = VehicleStatusBL.getDataByShopId(Convert.ToInt32(strShopId)); DateTime?dtImportDate = DateTime.TryParse(objImportData.File_Import_date, out dtOut) ? dtOut : (Nullable <DateTime>)null; DateTime?dtRepairStartDate = DateTime.TryParse(objImportData.Repair_Start_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null; DateTime?dtActualDeliveryDate = DateTime.TryParse(objImportData.Actual_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null; DateTime dtToday = DateTime.Today; //Update Vehicle Status depending Matching Date if (dtToday.Date.Equals(dtImportDate)) { strStatus = Constants.IMPORTED_ESTIMATE; bIsStatusChanged = true; } if (dtToday.Date.Equals(dtRepairStartDate)) { strStatus = Constants.INPROCESS_REPAIR; bIsStatusChanged = true; } if (dtToday.Date.Equals(dtActualDeliveryDate)) { strStatus = Constants.DELIVERED; bIsStatusChanged = true; } if (!bIsStatusChanged) { strStatus = Constants.UNSOLD_ESTIMATE; } if (lstVehicleStatus.Count > 0) { objTemp = lstVehicleStatus.Find(vs => vs.strVehicleStatus == strStatus); } if (objTemp != null) { objTemp = lstVehicleStatus.Find(vs => vs.strVehicleStatus == strStatus); iVehicleStatusId = objTemp.ID; objCustomerVehicleStatus.iVehicleStatusId = iVehicleStatusId; objCustomerVehicleStatus.dtLastUpdatedStatusDate = DateTime.Now; if (String.Equals(strStatus, Constants.DELIVERED)) { objCustomerVehicleStatus.dtDeliveryDate = DateTime.Now; } if (strStatus == Constants.UNSOLD_ESTIMATE || strStatus == Constants.DELIVERED) { objUser.bIsShowEmailMarketing = true; objUser.bIsShowTextMarketing = true; objUser.Save(); MarketingUsers objMarUser = MarketingUsers.getDataByShopAndUserId(Convert.ToInt32(strShopId), Convert.ToInt32(objUser.ID)); if (objMarUser != null) { objMarUser.bisShowInProcess = false; objMarUser.Save(); } } } else { VehicleStatusBL _objVehicleStatus = new VehicleStatusBL(); _objVehicleStatus.strVehicleStatus = strStatus; _objVehicleStatus.strMessage = String.Empty; _objVehicleStatus.iShopId = Convert.ToInt32(strShopId); _objVehicleStatus.bSMS = false; _objVehicleStatus.bIsActive = false; _objVehicleStatus.bEmail = false; if (_objVehicleStatus.Save()) { objCustomerVehicleStatus.iVehicleStatusId = _objVehicleStatus.ID; objCustomerVehicleStatus.dtLastUpdatedStatusDate = DateTime.Now; } } objCustomerVehicleStatus.Save(); }