public IHttpActionResult Add([FromBody] TblApiConnectionDto apiConnectionDto) { var data = this.apiConnectionService.GetByEnvironmentAndCategoryId(apiConnectionDto.EnvironmentId, apiConnectionDto.CategoryId); if (!data.IsError) { data.Messages.Add(new Message("Api Connection already exists with same environment and category combination!")); return(this.CreateCustomResponse(data, HttpStatusCode.BadRequest)); } return(this.AddUpdate(apiConnectionDto)); }
/// <summary> /// Adds the update. /// </summary> /// <param name="apiConnectionDto">The API connection dto.</param> /// <returns> /// Newly added object /// </returns> private IHttpActionResult AddUpdate(TblApiConnectionDto apiConnectionDto) { var result = new ResultMessage <TblApiConnectionDto>(); try { result = this.apiConnectionService.SaveOrUpdate(apiConnectionDto, this.UserId); } catch (Exception ex) { this.LoggerService.LogException(ex); result.Messages.Add(new Message(null, ex.Message)); } return(this.CreateCustomResponse(result)); }