示例#1
0
        public IHttpActionResult Add([FromBody] TblApiCategoriesDto apiCategoriesDto)
        {
            var data = this.apiCategoriesService.GetByName(apiCategoriesDto.Name);

            if (!data.IsError)
            {
                data.Messages.Add(new Message(null, "Api Categorie already exists with '" + apiCategoriesDto.Name + "' name!"));

                return(this.CreateCustomResponse(data, HttpStatusCode.BadRequest));
            }

            return(this.AddUpdate(apiCategoriesDto));
        }
示例#2
0
        public IHttpActionResult Update([FromBody] TblApiCategoriesDto apiCategoriesDto, long categoryId)
        {
            var data = this.apiCategoriesService.GetByName(apiCategoriesDto.Name);

            if (!data.IsError && data.Item != null && categoryId != data.Item.Id)
            {
                data.Messages.Add(new Message(null, "Action already exists with '" + apiCategoriesDto.Name + "' name!"));

                return(this.CreateCustomResponse(data, HttpStatusCode.BadRequest));
            }

            apiCategoriesDto.Id = categoryId;
            return(this.AddUpdate(apiCategoriesDto));
        }
示例#3
0
        /// <summary>
        /// Adds the update.
        /// </summary>
        /// <param name="apiCategoriesDto">The API categories dto.</param>
        /// <returns>
        /// Newly added object
        /// </returns>
        private IHttpActionResult AddUpdate(TblApiCategoriesDto apiCategoriesDto)
        {
            var result = new ResultMessage <TblApiCategoriesDto>();

            try
            {
                result = this.apiCategoriesService.SaveOrUpdate(apiCategoriesDto, this.UserId);
            }
            catch (Exception ex)
            {
                this.LoggerService.LogException(ex);
                result.Messages.Add(new Message(null, ex.Message));
            }

            return(this.CreateCustomResponse(result));
        }