Example #1
0
        public async System.Threading.Tasks.Task <ActionResult> PutAsync(string projectId, string problemId, string betId, Models.BetComment.BetCommentNewUpdate form)
        {
            try
            {
                // Checks we have a valid request.
                if (form == null || !ModelState.IsValid)
                {
                    return(this.BadRequest());
                }

                // Gets the problem and checks the project id / bet id is valid against it.
                var problem = await this._problemServices.GetAsync(projectId, problemId);

                if (problem.ProjectId != ProjectSpeedy.Services.Project.PREFIX + projectId ||
                    !problem.Bets.Any(b => b.Id == ProjectSpeedy.Services.Bet.PREFIX + betId))
                {
                    return(this.NotFound());
                }

                // Tries to add the comment
                if (await this._betCommentService.CreateAsync(projectId, problemId, betId, form))
                {
                    return(this.Accepted());
                }

                // If we get here something has gone wrong.
                return(this.Problem());
            }
            catch (HttpRequestException e)
            {
                // Can we find the problem.
                if (e.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    return(NotFound());
                }

                // There has been a problem loading or saving data.
                this._logger.LogError(e, e.Message);
                return(this.Problem());
            }
            catch (Exception e)
            {
                this._logger.LogError(e, e.Message);
                return(this.Problem());
            }
        }
Example #2
0
 public ActionResult Post(string projectId, string problemId, string betId, string commentId, Models.BetComment.BetCommentNewUpdate form)
 {
     try
     {
         return(this.Accepted());
     }
     catch (Exception e)
     {
         this._logger.LogError(e, e.Message);
         return(this.Problem());
     }
 }