Exemplo n.º 1
0
        /// <summary>
        /// Set job info into session
        /// </summary>
        /// <param name="model"></param>
        public void SetJobInfo(BookRepair_JobModel model)
        {
            var product  = new ProductService(_dataContext);
            var prodInfo = new Product_InfoModel();
            var book     = _bookStateHolder.Load();

            // fill model for product info
            prodInfo.ItemNumber        = product.GetModelNumber();
            prodInfo.Description       = product.GetModelDescr();
            prodInfo.ModelBrand        = product.GetModelBrand();
            prodInfo.OriginalCondition = model.ItemCondition;
            prodInfo.SerialNumber      = model.SerialNumber;
            prodInfo.TransactionInfo   = model.TransNumber;
            prodInfo.DateOfPurchase    = model.DateOfPurchase ?? DateTime.Now;
            prodInfo.Additionalfields  = model.AdditionalFields;
            // save product info in session
            product.SetGeneralProductInfoInSession(prodInfo);

            book.DateOfPurchase = model.DateOfPurchase;
            book.StoreNumber    = model.StoreNumber;
            book.TillNumber     = model.TillNumber;

            book.Type                 = model.SelectedType;
            book.FaultDescr           = model.FaultDescr;
            book.DateOfPurchaseString = model.DateOfPurchaseString;
            book.EngineerId           = model.EngineerId;
            book.FieldsForInspection  = model.AdditionalFields;
            book.AppointmentDate      = model.AppointmentDate;
            book.StoreCollection      = model.StoreCollection;
            book.Slotid               = model.Slotid;
            _bookStateHolder.UpdateFrom(book);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get job info
        /// </summary>
        /// <returns>Return model</returns>
        public BookRepair_JobModel GetJobInfo()
        {
            var book       = _bookStateHolder.Load();
            var Inspection = new InspectionService(_dataContext);
            var result     = new BookRepair_JobModel();
            var store      = new StoreService(_dataContext);

            // if mandatory fields are null and service id is exist, then load from DB
            if ((book.FaultDescr == null) && (book.DateOfPurchase == null) && (book.ServiceId.HasValue))
            {
                result = _reporsitory.GetAcceptingJobInfo(book.ServiceId ?? 0);

                //book.AcceptJobFlag = false;
                _bookStateHolder.UpdateFrom(book);
            }

            // if normal booking process, then get info from session
            //if (!book.AcceptJobFlag)
            else
            {
                var product = new ProductService(_dataContext);

                var prodInfo = product.GetGeneralInfoFromSession();

                result.SerialNumber   = prodInfo.SerialNumber;
                result.ItemCondition  = prodInfo.OriginalCondition;
                result.DateOfPurchase = prodInfo.DateOfPurchase;

                result.StoreNumber          = book.StoreNumber;// == null ?store.GetStoreId().ToString(): book.StoreNumber;
                result.TillNumber           = book.TillNumber;
                result.TransNumber          = prodInfo.TransactionInfo;
                result.SelectedType         = book.Type;
                result.FaultDescr           = book.FaultDescr;
                result.EngineerId           = book.EngineerId;
                result.DateOfPurchaseString = book.DateOfPurchaseString;
                result.AdditionalFields     = book.FieldsForInspection == null?Inspection.GetSpecificInspection() : book.FieldsForInspection; //prodInfo.Additionalfields
            }
            //  result.AdditionalFields = book.FieldsForInspection == null ? Inspection.GetSpecificInspection() : book.FieldsForInspection;
            result.Type = GetJobTypesList();
            //  result.AdditionalFields = Inspection.GetSpecificInspection();
            result.AppointmentDate = book.AppointmentDate;
            //result.StoreCollection = book.StoreCollection;
            result.OnlineBookingFailed = book.OnlineBookingFailed;
            var repairAgent = GetAgentRepairInfo();

            result.BookingUrl      = repairAgent.BookingUrl;
            result.InHomeAvailable = repairAgent.InHomeAvailable;
            if (!string.IsNullOrEmpty(repairAgent.BookingUrl))
            {
                result.StoreCollection = book.StoreCollection;// !repairAgent.InHomeAvailable ? true :
            }
            return(result);
        }
Exemplo n.º 3
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);
        }