예제 #1
0
        public ResponseWrapper <BaseContactResponse> Add(AddContactRequest request)
        {
            ResponseWrapper <BaseContactResponse> response;

            response = ResponseWrapper <BaseContactResponse> .GetInternalServerErrorResponse();

            try
            {
                object parameters = new
                {
                    FirstName   = request.FirstName,
                    LastName    = request.LastName,
                    PhoneNumber = request.PhoneNumber,
                    Email       = request.Email,
                    Status      = request.Status
                };

                string errorCode, errorMessage;
                bool   result = false;

                var transaction = _contactDAL.GetByParam(parameters, DBCommands.USP_ContactDetails_Add, out result, out errorMessage, out errorCode);
                if (result == false)
                {
                    response = ResponseWrapper <BaseContactResponse> .GetForbiddenErrorResponse(errorMessage);
                }
                else
                {
                    response = ResponseWrapper <BaseContactResponse> .GetSuccessResponse();

                    response.data = new BaseContactResponse();
                    response.data = Mapper.Map <BaseContactResponse>(transaction);
                }
            }
            catch (Exception ex)
            {
                response = ResponseWrapper <BaseContactResponse> .GetForbiddenErrorResponse(ex.Message);

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