Exemple #1
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);
        }