Example #1
0
        private void GetChecklistDetailsForSite(CompanyDetails companyDetails, CompanyDetailsResponse result)
        {
            var checklists = _checklistRepository
                .GetByClientId(clientId: result.Id, includeDeleted:false)
                .ToList();

            if (checklists.Any())
            {
                foreach (var site in companyDetails.Sites)
                {
                    var checklistForSite = checklists.FirstOrDefault(c => c.SiteId == site.Id && c.Status != Checklist.STATUS_SUBMITTED);
                    if (checklistForSite != null)
                    {
                        var checklistModel = new ChecklistDetails
                                                 {
                                                     Id = checklistForSite.Id,
                                                     VisitDate = checklistForSite.VisitDate,
                                                     VisitBy = checklistForSite.VisitBy,
                                                     CreatedOn = checklistForSite.CreatedOn,
                                                 };
                        site.Checklist = checklistModel;
                    }
                }
            }
        }
        public CompanyDetails Get(int id)
        {
            //http://clientdetailsservicesrest/RestService/v1.0/Client/{ID}
            var request = new RestRequest("Client/{ID}", Method.GET)
            {
                RequestFormat = DataFormat.Xml
            };

            request.AddUrlSegment("ID", id.ToString());


            var result = _restClient.Execute<CompanyDetailsResponse>(request);

            var companyDetails = new CompanyDetails() { CAN = result.Data.CAN, CompanyName = result.Data.CompanyName, Id = result.Data.Id, Industry = result.Data.Industry};
            companyDetails.Sites = GetSites(companyDetails.Id).Select(x => new SiteDetails
                                                                               {
                                                                                   Id = x.Id,
                                                                                   Address1 = x.Address1,
                                                                                   Address2 = x.Address2,
                                                                                   Address3 = x.Address3,
                                                                                   Address4 = x.Address4,
                                                                                   Address5 = x.Address5,
                                                                                   County = x.County,
                                                                                   Postcode = x.Postcode,
                                                                                   Telephone = x.Telephone,
                                                                                   SiteContact = x.SiteContact,
                                                                                   SiteName = x.SiteName
                                                                               }).ToList();

            return companyDetails;
        }
Example #3
0
        public CompanyDetails Query(string clientAccountNumber)
        {
            var result = _clientDetailsService.GetByClientAccountNumber(clientAccountNumber);

            if (result == null || result.Id  == -1)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var companyDetails = new CompanyDetails() {CAN = result.CAN, CompanyName = result.CompanyName, Id = result.Id, Industry = result.Industry};
            var sites = _clientDetailsService.GetSites(companyDetails.Id);

            if (sites.Any())
            {
                companyDetails.Sites =
                    sites.InculdeMainAndAllHealthAndSafetySitesOnly().Select(x => new SiteDetails
                                                                                      {
                                                                                          Id = x.Id,
                                                                                          Address1 = x.Address1,
                                                                                          Address2 = x.Address2,
                                                                                          Address3 = x.Address3,
                                                                                          Address4 = x.Address4,
                                                                                          Address5 = x.Address5,
                                                                                          County = x.County,
                                                                                          Postcode = x.Postcode,
                                                                                          Telephone = x.Telephone,
                                                                                          SiteContact = x.SiteContact,
                                                                                          SiteName = x.SiteName
                                                                                      }).ToList();

                GetChecklistDetailsForSite(companyDetails, result);
            }

            UpdateSiteNameToCompanyNameIfNullOrEmpty(companyDetails);
            return companyDetails;
        }
Example #4
0
 private static void UpdateSiteNameToCompanyNameIfNullOrEmpty(CompanyDetails clientDetails)
 {
     if (clientDetails.Sites != null)
     {
         clientDetails.Sites.ForEach(x => { x.SiteName = string.IsNullOrEmpty(x.SiteName) ? clientDetails.CompanyName : x.SiteName; });
     }
 }