コード例 #1
0
        /// <summary>
        /// Update tax value
        /// </summary>
        /// <param name="obj">New Tax value</param>
        /// <returns></returns>
        public ApiResponseViewModel Update(Model.Models.Type obj)
        {
            var result   = new TypeViewModel();
            var response = new ApiResponseViewModel
            {
                Code    = CommonConstants.ApiResponseSuccessCode,
                Message = null,
                Result  = null
            };

            try
            {
                var exists = _TypeRepository.CheckContains(m => m.ID == obj.ID);
                if (exists)
                {
                    _TypeRepository.Update(obj);
                    _unitOfWork.Commit();
                    response.Message = CommonConstants.SaveSuccess;
                }
                else
                {
                    response.Code    = CommonConstants.ApiResponseNotFoundCode;
                    response.Message = CommonConstants.NotFoundMessage;
                }
            }
            catch (Exception ex)
            {
                response.Code    = CommonConstants.ApiResponseExceptionCode;
                response.Message = CommonConstants.ErrorMessage + " " + ex.Message;
            }

            return(response);
        }
コード例 #2
0
        /// <summary>
        /// Make Tax value in-active by Id
        /// </summary>
        /// <param name="id">ID of Tax value</param>
        /// <returns></returns>
        public ApiResponseViewModel SetInActive(int id)
        {
            var result   = new Model.Models.Type();
            var response = new ApiResponseViewModel
            {
                Code    = CommonConstants.ApiResponseSuccessCode,
                Message = null,
                Result  = null
            };

            try
            {
                var exists = _TypeRepository.CheckContains(m => m.ID == id);
                if (exists)
                {
                    result          = _TypeRepository.GetSingleById(id);
                    result.IsActive = false;
                    _TypeRepository.Update(result);
                    _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);
        }
コード例 #3
0
 public ApiResponseViewModel Update(Model.Models.Type obj)
 {
     if (HttpContext.Current.Session["UserLogged"] == null)
     {
         return(CommonConstants.accessDenied);
     }
     return(_TypeService.Update(obj));
 }
コード例 #4
0
        /// <summary>
        /// Constructor for managing types - gets types if update, else null
        /// </summary>
        /// <param name="knxObject"></param>
        /// <param name="rooms"></param>
        /// <param name="types"></param>
        public NewTypePage(Type type)
        {
            InitializeComponent();

            Type     = type ?? new Type();
            IsUpdate = type != null ? true : false;

            Title = IsUpdate ? "Uredi tip" : "Novi tip";

            BindingContext = this;
        }
コード例 #5
0
ファイル: TypeController.cs プロジェクト: war-man/TheShoes
 public HttpResponseMessage Create(HttpRequestMessage request, TypeViewModel typeVm)
 {
     if (ModelState.IsValid)
     {
         var newType = new Model.Models.Type();
         newType.UpdateType(typeVm);
         try
         {
             _typeService.Add(newType);
             _typeService.Save();
             return(request.CreateResponse(HttpStatusCode.OK, typeVm));
         }
         catch (NameDuplicatedException dex)
         {
             return(request.CreateErrorResponse(HttpStatusCode.BadRequest, dex.Message));
         }
     }
     else
     {
         return(request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
 }
コード例 #6
0
        /// <summary>
        /// Add new Tax value
        /// </summary>
        /// <param name="obj">Tax value</param>
        /// <returns></returns>
        public ApiResponseViewModel Add(Model.Models.Type obj)
        {
            var result   = new Model.Models.Type();
            var response = new ApiResponseViewModel
            {
                Code    = CommonConstants.ApiResponseSuccessCode,
                Message = null,
                Result  = null
            };

            try
            {
                result = _TypeRepository.Add(obj);
                _unitOfWork.Commit();
                response.Message = CommonConstants.AddSuccess;
                response.Result  = result;
            }
            catch (Exception ex)
            {
                response.Code    = CommonConstants.ApiResponseExceptionCode;
                response.Message = CommonConstants.ErrorMessage + " " + ex.Message;
            }
            return(response);
        }
コード例 #7
0
 public EditType(IRepository <Model.Models.Type> repository, Model.Models.Type type)
 {
     _repository = repository;
     _type       = type;
     InitializeComponent();
 }
コード例 #8
0
 public static void UpdateType(this Model.Models.Type type, TypeViewModel typeVm)
 {
     type.ID   = typeVm.ID;
     type.Name = typeVm.Name;
 }