Пример #1
0
        public void BookDPAFAILJob(string EventDate, int Engineerid, string faultdesc, string reason = "", JobType type = JobType.Defaulttype)
        {
            bool   tempServiceId = false;
            var    result        = new OnlineBookResponseDetails();
            bool   success       = false;
            string FormPath      = string.Empty;
            int    serviceid     = 0;
            string visitdate     = string.Empty;
            string userid        = storeService.UserId;
            var    errorMsg      = "Job Booking failed";
            var    errorDetails  = string.Empty;

            OnlineBookRequestDetails model = new OnlineBookRequestDetails();

            //  model.InjectFrom(ProductService.SessionInfo);
            model.Postcode = customerService.SessionInfo.Postcode;
            //model.EngineerID = Engineerid ;
            model.VisitDate = DateTime.Parse(EventDate);
            //model.StatusID = 4;
            //  model.Model = DPAservice.SessionInfo. ProductService.SessionInfo.ItemCode;
            model.CustomerID = customerService.SessionInfo.CustomerId;// CustomerService.SessionInfo.CustomerId;
            model.CustAplID  = onlineBookingService.addCustApl(model.CustomerID, JobType.DPAfailure);
            //model.CustAplID = BookService.SessionInfo.CustProd.CustAplId;// ProductService.SessionInfo.CustaplId;

            model.ReportFault = faultdesc;
            //model.SNO = BookService.SessionInfo.CustProd.SerialNumber;
            //model.PolicyNumber = BookService.SessionInfo.CustProd.PolicyNumber;
            //model.AuthNo = BookService.SessionInfo.CustProd.AuthNo;
            model.ClientID = storeService.StoreId;

            if (type != JobType.Defaulttype)
            {
                if (specialJob != null && specialJob.Count() > 0)
                {
                    model.EngineerID = specialJob.Where(x => x.JobTypeid == (int)type).First().EngId;
                    model.VisitCode  = specialJob.Where(x => x.JobTypeid == (int)type).First().VisitType;
                    model.StatusID   = specialJob.Where(x => x.JobTypeid == (int)type).First().StatusId;
                    model.Skills     = specialJob.Where(x => x.JobTypeid == (int)type).First().Skill;
                }
            }



            var response = onlineBookingService.BookJob(model);

            if (response.BookSuccessfully)
            {
                //FormPath = string.Format("BookedJobConfirmation?Serviceid={0}&engineerid={1}&eventdate={2}&tempServiceId={3}", response.ServiceID, Engineerid, EventDate, tempServiceId);
                //success = response.BookSuccessfully;
                serviceid = response.ServiceID;
                visitdate = model.VisitDate.ToString();
                ServiceModel serviceModel = new ServiceModel();
                serviceModel.InjectFrom(response);
                serviceModel.Engineerid  = Engineerid;
                serviceModel.CustomerID  = BookService.SessionInfo.CustomerId;
                serviceModel.CustAplID   = BookService.SessionInfo.CustProd.CustAplId;
                serviceModel.EventDate   = model.VisitDate.ToString();
                serviceModel.Reportfault = model.ReportFault;
                serviceModel.ClientId    = model.ClientID;
                serviceModel.VisitCode   = model.VisitCode;
                serviceModel.Clientref   = model.ClientRef;
                serviceModel.StatusId    = model.StatusID;
                int Serviceid = JobService.CreateJobwithEngineer(serviceModel);
            }
            // return RedirectToAction("Index", "Home");
        }
Пример #2
0
        /// <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.ErrorFormat("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);
        }