Example #1
0
        /// <summary>
        /// Delete CustomerType by Id
        /// </summary>
        /// <param name="id">ID of CustomerType</param>
        /// <returns></returns>
        public ApiResponseViewModel Delete(int id)
        {
            var result   = new CustomerType();
            var response = new ApiResponseViewModel
            {
                Code    = CommonConstants.ApiResponseSuccessCode,
                Message = null,
                Result  = null
            };

            try
            {
                var exists = _customerTypeRepository.CheckContains(m => m.ID == id);
                if (exists)
                {
                    result = _customerTypeRepository.Delete(id);
                    _unitOfWork.Commit();
                    response.Message = CommonConstants.DeleteSuccess;
                    response.Result  = result;
                }
                else
                {
                    response.Code    = CommonConstants.ApiResponseNotFoundCode;
                    response.Message = CommonConstants.NotFoundMessage;
                }
            }
            catch (Exception ex)
            {
                response.Code    = CommonConstants.ApiResponseExceptionCode;
                response.Message = CommonConstants.ErrorMessage + " " + ex.Message;
            }
            return(response);
        }