public IHttpActionResult Add(long websiteId, [FromBody] TblTestCategoriesDto testCatDto) { testCatDto.WebsiteId = websiteId; var data = this.testCategoryService.GetByName(testCatDto.Name, testCatDto.WebsiteId); if (!data.IsError) { data.Messages.Add(new Message(null, "Category already exists with '" + testCatDto.Name + "' name!")); return(this.CreateCustomResponse(data, HttpStatusCode.BadRequest)); } return(this.AddUpdate(testCatDto)); }
/// <summary> /// Adds the update. /// </summary> /// <param name="testCatDto">The display name dto.</param> /// <returns> /// Newly added object /// </returns> private IHttpActionResult AddUpdate(TblTestCategoriesDto testCatDto) { var result = new ResultMessage <TblTestCategoriesDto>(); try { result = this.testCategoryService.SaveOrUpdate(testCatDto, this.UserId); } catch (Exception ex) { this.LoggerService.LogException(ex); result.Messages.Add(new Message(null, ex.Message)); } return(this.CreateCustomResponse(result)); }