/// <summary> /// Save job into database /// </summary> /// <returns></returns> public int SaveJob() { var book = _bookStateHolder.Load(); //if(book.AppointmentDate!="") var cust = new CustomerService(_dataContext); var prod = new ProductService(_dataContext); var user = new UserService(_dataContext); var store = new StoreService(_dataContext); var job = new BookRepair_JobModel(); var quest = new QuestionService(_dataContext); var jobService = new JobService(_dataContext); var prodInfo = prod.GetGeneralInfoFromSession(); var repairAgent = GetAgentRepairInfo(); job.DateOfPurchase = book.DateOfPurchase; job.SerialNumber = prodInfo.SerialNumber; job.ItemCondition = prodInfo.OriginalCondition; job.DateOfPurchase = prodInfo.DateOfPurchase; job.StoreNumber = book.StoreNumber; job.TillNumber = book.TillNumber; job.TransNumber = prodInfo.TransactionInfo; job.SelectedType = book.Type; job.FaultDescr = book.FaultDescr + " \n" + quest.GetAnswersFromSession(); job.UserID = user.GetUserId(); job.EngineerId = book.EngineerId; job.AppointmentDate = book.AppointmentDate; job.StoreCollection = book.StoreCollection; SetAcceptJobFlag(false); int custId = cust.GetCustomerIdFromSession(); var customer = cust.GetCustomerInfo(); int Jobid = _reporsitory.UpdateJob(job, custId, prod.GetModelId(), (DateTime)prod.GetTimeBookRepairClick(), book.ServiceId, store.GetStoreId()); if (!string.IsNullOrEmpty(repairAgent.BookingUrl)) { OnlineBookingService onlineBookingService = new OnlineBookingService(); OnlineBookRequestDetails model = new OnlineBookRequestDetails(); // model.InjectFrom(ProductService.SessionInfo); model.ServiceID = Jobid; model.CustomerTitle = customer.TitleName; model.CustomerForename = customer.Forename; model.CustomerSurname = customer.Surname; model.CustomerStreet = customer.Addr1; model.CustomerPostcode = customer.Postcode; model.CustomerAddressTown = customer.Town; model.CustomerWorkTelNo = customer.LandlineTel; model.CustomerMobileNo = customer.MobileTel; model.CustomerEmailAddress = customer.Email; model.SupplyDat = prodInfo.DateOfPurchase.ToString("yyyy-MM-dd"); //model.CustAplID = prodInfo.CustaplId; model.ApplianceCD = ""; //model.Model = prodInfo.ItemNumber; //model.AltCode = prodInfo.ItemCode; // cast online booking - skyline Argos Cat No (MODEL) should go into Skyline ProductCode field //Argos Brand Model (ALTCODE) should go into Skyline ModelNo field model.Model = prodInfo.ItemCode; model.AltCode = prodInfo.ItemNumber; model.SNO = job.SerialNumber; model.MFR = prodInfo.ModelBrand; //model.PolicyNumber =prodInfo.p model.ReportFault = job.FaultDescr; model.ClientID = store.GetStoreId(); model.StatusID = 4; // model.VisitDate = DateTime.Parse(job.AppointmentDate); // model.EngineerID = job.EngineerId.Value; model.SlotID = book.Slotid; // model.CallType = job.StoreCollection ? "1 Store Collection" : "2 In Home Repair";//repairAgent.InHomeAvailable?"1 Store Collection":( job.StoreCollection ? "1 Store Collection" : "2 In Home Repair"); model.CallType = !repairAgent.InHomeAvailable ? "1 Store Collection":(job.StoreCollection ? "1 Store Collection" : "2 In Home Repair"); var response = onlineBookingService.BookJob(model); Log.File.InfoFormat("Error {0}: {1}. ", response.ErrorMsg, response.BookSuccessfully); if (response.BookSuccessfully) { _reporsitory.UpdateJobClientRef(Jobid, response.ServiceID); HttpContext.Current.Session["ClientRef"] = response.ServiceID; } else { book.OnlineBookingFailed = true; } } if (book.FieldsForInspection != null && book.FieldsForInspection.Count > 0) { InspectionRepository ins = new InspectionRepository(_dataContext); book.FieldsForInspection.ForEach(s => s.ServiceId = Jobid); ins.SaveSpecificInspection(book.FieldsForInspection); } return(Jobid); }