Esempio n. 1
0
        /// <summary>
        /// Get Tax value by id
        /// </summary>
        /// <param name="id">ID of Tax value</param>
        /// <returns></returns>
        public ApiResponseViewModel GetById(int id)
        {
            var result   = new TypeViewModel();
            var response = new ApiResponseViewModel
            {
                Code    = CommonConstants.ApiResponseSuccessCode,
                Message = null,
                Result  = null
            };

            try
            {
                var exists = _TypeRepository.CheckContains(m => m.ID == id);
                if (exists)
                {
                    var tempResult = _TypeRepository.GetSingleById(id);
                    result.ID       = tempResult.ID;
                    result.TypeName = tempResult.TypeName;
                    result.IsActive = tempResult.IsActive ?? false;
                    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);
        }
Esempio n. 2
0
 public Type Add(Type type)
 {
     if (_typeRepository.CheckContains(x => x.Name == type.Name))
     {
         throw new NameDuplicatedException("Tên không được trùng");
     }
     return(_typeRepository.Add(type));
 }