示例#1
0
        /// <summary>
        /// Get customer info
        /// </summary>
        /// <returns></returns>
        public CustomerModel GetCustomerInfo(int customerId)
        {
            try
            {
                //   var res = new CustomerModel();
                // Get customer info
                var model   = Repository.GetCustomerInfo(customerId) ?? new CustomerModel();
                var country = string.IsNullOrEmpty(model.Country) ? StoreCountry : model.Country;
                model.TitleList                = GetTitlesList(model.Title);
                model.ContactMethodList        = GetContactMethodList(model.ContactMethod.ToString());
                model.CountryList              = GetCountryList(country);
                model.FailureRepairReasonsList = GetFailureRepairReasons();
                var ClientList = storeRepository.ClientList();
                model.ClientName = ClientList.Where(x => x.StoreId == int.Parse(model.ClientId)).FirstOrDefault().StoreName;
                var CustomerProduct = CLC_GetCustomerProductsbyCustomerid(customerId); // GetCustomerProducts(customerId);

                List <Product_InfoModel> Productinfos = new List <Product_InfoModel>();
                foreach (CustAplModel item in CustomerProduct)
                {
                    Product_InfoModel prodModel = new Product_InfoModel();
                    prodModel.InjectFrom(item);
                    prodModel.DateOfPurchase  = item.DateOfPurchase;
                    prodModel.CONTRACTSTART   = item.CONTRACTSTART;
                    prodModel.CONTRACTEXPIRES = item.CONTRACTEXPIRES;
                    prodModel.PolicyNumber    = item.PolicyNumber;
                    prodModel.RegNo           = item.RegNo;
                    prodModel.Brand           = item.Brand;
                    AddressDetails address = new AddressDetails();
                    address.InjectFrom(item);
                    prodModel.addressDetails = address;
                    Productinfos.Add(prodModel);
                }
                //  Productinfos.InjectFrom(CustomerProduct);
                model.ProductInfoModel = Productinfos;


                //var result = new ClientConnect.ViewModels.Job.JobDetailsModel();

                //  var JobNotes = RepositoryJob.GetJobNotesForShop(customerId);


                //  foreach (var item in model.ProductInfoModel)
                //  {
                //      //item.JobNotes  = RepositoryJob.GetJobDetailsByCustomerAppliance(item.serviceId);
                //     item. ServiceDetails = RepositoryJob.GetJobDetailsByCustomerAppliance(item.serviceId);
                //    // model.JobDetails = RepositoryJob.GetJobDetailsByCustomerAppliance(item.serviceId);//Job_NoteDto

                //     item.JobNotes = JobNotes.Select(noteDto =>
                //new NoteRecordModelShop()
                //{
                //    ServiceId=noteDto.ServiceId,
                //    DateTime = noteDto.DateTime,
                //    From = noteDto.From,
                //    Notes = noteDto.Notes
                //}).ToList();


                //     item.noteModelDetails.AllPageofNotes = item.JobNotes.ToPagedList(1, 20);
                //     item.noteModelDetails.NotesModel = item.JobNotes;


                //    // item.JobNotes.ToPagedList(page ?? 1, 20);
                //     //res.JobDetails = RepositoryJob.GetJobDetailsByCustomerAppliance(item.serviceId).ToList();//Job_NoteDto

                //     // item.JobNotes = RepositoryJob.GetJobDetailsByCustomerAppliance(item.ServiceDetails.ServiceId);
                //  }

                //   res = model;


                //model.NotesModel = Repository.getCustomerNotes(customerId);

                return(model);
            }
            catch (Exception e)
            {
                throw new HttpException(500, string.Format("Error in method. Method:{0}. Error:{1}", "GetCustomerInfo", e.Message));
            }
        }