Ejemplo n.º 1
0
        public AuthorisedPersonModel GetAuthorisedPerson(int?id)
        {
            if (id == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
            AuthorisedPersonModel authorisedperson = _authorisedperson.GetAuthorisedPerson((int)id);

            return(authorisedperson);
        }
Ejemplo n.º 2
0
        public AuthorisedPersonModel GetAuthorisedPerson(int authorisedpersonId)
        {
            AuthorisedPerson      authorisedperson      = AuthorisedPersonRepository.AuthorisedPersons.SingleOrDefault(ap => ap.AuthorisedPersonId == authorisedpersonId);
            AuthorisedPersonModel authorisedPersonModel = new AuthorisedPersonModel();

            if (authorisedperson.AuthorisedPersonAgencyId == null)
            {
                if (authorisedperson.AuthorisedPersonPromoterId != null)
                {
                    Promoter promoter = PromoterRepository.Promoters.SingleOrDefault(p => p.PromoterId == authorisedperson.AuthorisedPersonPromoterId);
                    if (promoter != default(Promoter))
                    {
                        authorisedPersonModel = new AuthorisedPersonModel
                        {
                            AuthorisedPersonId = authorisedperson.AuthorisedPersonId,
                            CompanyId          = authorisedperson.CompanyId,
                            Name                       = authorisedperson.Name,
                            Role                       = authorisedperson.Role,
                            ContactNumber              = authorisedperson.ContactNumber,
                            LandlineNumber             = authorisedperson.LandlineNumber,
                            IsCoordinator              = authorisedperson.IsCoordinator,
                            Email                      = authorisedperson.Email,
                            AgencyType                 = "Promoter",
                            AgencyName                 = promoter.Name,
                            AgencyAddress              = promoter.OfficeAddress,
                            AuthorisedPersonAgencyId   = authorisedperson.AuthorisedPersonAgencyId,
                            AuthorisedPersonPromoterId = authorisedperson.AuthorisedPersonPromoterId,
                            CreatedDate                = authorisedperson.CreatedDate,
                            CreatedBy                  = authorisedperson.CreatedBy
                        }
                    }
                    ;
                }
                else
                {
                    Company company = CompanyRepository.Companys.SingleOrDefault(c => c.CompanyId == authorisedperson.CompanyId);
                    if (company != default(Company))
                    {
                        authorisedPersonModel = new AuthorisedPersonModel
                        {
                            AuthorisedPersonId = authorisedperson.AuthorisedPersonId,
                            CompanyId          = authorisedperson.CompanyId,
                            Name                       = authorisedperson.Name,
                            Role                       = authorisedperson.Role,
                            ContactNumber              = authorisedperson.ContactNumber,
                            LandlineNumber             = authorisedperson.LandlineNumber,
                            IsCoordinator              = authorisedperson.IsCoordinator,
                            Email                      = authorisedperson.Email,
                            AgencyType                 = "Company",
                            AgencyName                 = company.CompanyName,
                            AgencyAddress              = company.RegisteredAddress,
                            AuthorisedPersonAgencyId   = authorisedperson.AuthorisedPersonAgencyId,
                            AuthorisedPersonPromoterId = authorisedperson.AuthorisedPersonPromoterId,
                            CreatedDate                = authorisedperson.CreatedDate,
                            CreatedBy                  = authorisedperson.CreatedBy
                        }
                    }
                    ;
                }
            }
            else
            {
                Agency agency = AgencyRepository.Agencys.SingleOrDefault(a => a.AgencyId == authorisedperson.AuthorisedPersonAgencyId);
                if (agency != default(Agency))
                {
                    authorisedPersonModel = new AuthorisedPersonModel
                    {
                        AuthorisedPersonId = authorisedperson.AuthorisedPersonId,
                        CompanyId          = authorisedperson.CompanyId,
                        Name                       = authorisedperson.Name,
                        Role                       = authorisedperson.Role,
                        IsCoordinator              = authorisedperson.IsCoordinator,
                        ContactNumber              = authorisedperson.ContactNumber,
                        LandlineNumber             = authorisedperson.LandlineNumber,
                        Email                      = authorisedperson.Email,
                        AgencyType                 = agency.AgencyType,
                        AgencyName                 = agency.AgencyName,
                        AgencyAddress              = agency.AgencyAddress,
                        AuthorisedPersonAgencyId   = authorisedperson.AuthorisedPersonAgencyId,
                        AuthorisedPersonPromoterId = authorisedperson.AuthorisedPersonPromoterId,
                        CreatedDate                = authorisedperson.CreatedDate,
                        CreatedBy                  = authorisedperson.CreatedBy
                    }
                }
                ;
            }

            return(authorisedPersonModel);
        }