Example #1
0
        public IHttpActionResult Add([FromBody] TblTestDto testDto)
        {
            var data = this.testService.GetByName(testDto.TestName, testDto.WebsiteId);

            if (!data.IsError)
            {
                data.Messages.Add(new Message(null, "Website already exists with '" + testDto.TestName + "' name!"));

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

            return(this.AddUpdate(testDto));
        }
Example #2
0
        /// <summary>
        /// Adds the update.
        /// </summary>
        /// <param name="testDto">The test dto.</param>
        /// <returns>
        /// Newly added object
        /// </returns>
        private IHttpActionResult AddUpdate(TblTestDto testDto)
        {
            var result = new ResultMessage <TblTestDto>();

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

            return(this.CreateCustomResponse(result));
        }