public async Task <ActionResult> PostAsync([FromBody] PlanDTO value)
        {
            try
            {
                var success = await planService.AddAsync(value);

                if (success)
                {
                    string okMessage = $"Succesfully created plan: {value.Name}";
                    return(Ok(okMessage));
                }
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
            string message = "Incorrect request syntax.";

            return(BadRequest(message));
        }
Example #2
0
        public async Task <HttpResponseMessage> PostAsync([FromBody] PlanDto value)
        {
            try
            {
                var success = await planService.AddAsync(value);

                if (success)
                {
                    var log = $"Succesfully created plan {value.Name} with id = {value.Id} by user with id = {value.CreatorId}";
                    tracer.Info(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, log);
                    var okMessage = $"Succesfully created plan: {value.Name}";
                    return(Request.CreateResponse(HttpStatusCode.OK, okMessage));
                }
            }
            catch (EntityException e)
            {
                tracer.Error(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, e);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
            }
            tracer.Warn(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, "Error occured on creating plan");
            const string message = "Incorrect request syntax.";

            return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, message));
        }
Example #3
0
 public Task <IActionResult> AddAsync(PlanModel model)
 {
     return(_planService.AddAsync(model).ResultAsync());
 }