Пример #1
0
        public ResponseWrapper <GetContactResponse> Get()
        {
            ResponseWrapper <GetContactResponse> response;

            response = ResponseWrapper <GetContactResponse> .GetInternalServerErrorResponse();

            try
            {
                var contacts = _contactDAL.GetAll(null, DBCommands.USP_ContactDetails_GetAll);
                response = ResponseWrapper <GetContactResponse> .GetSuccessResponse();

                response.data          = new GetContactResponse();
                response.data.Contacts = new List <ContactDetails>();
                foreach (var contact in contacts)
                {
                    response.data.Contacts.Add(new ContactDetails()
                    {
                        ID          = contact.ID,
                        FirstName   = contact.FirstName,
                        LastName    = contact.LastName,
                        Email       = contact.Email,
                        PhoneNumber = contact.PhoneNumber,
                        Status      = contact.Status,
                    });
                }
            }
            catch (Exception ex)
            {
                response = ResponseWrapper <GetContactResponse> .GetForbiddenErrorResponse(ex.Message);

                LogManager.WriteError("ContactServices:Get" + ex.Message);
            }
            return(response);
        }