コード例 #1
0
 public IActionResult Post([FromBody] Goal goal)
 {
     if (GoalDataAccess.Add(goal))
     {
         return(Created($"/api/Goals/{goal.Email}", goal));
     }
     else
     {
         return(new BadRequestResult());
     }
 }
コード例 #2
0
 public List <Goals> GetModuleQuestions(int UserId, int PoeId)
 {
     try
     {
         GoalDataAccess goal = new GoalDataAccess();
         return(goal.GetModuleQuestions(UserId, PoeId));
     }
     catch (Exception e)
     {
         WebOperationContext.Current.OutgoingResponse.StatusCode        = HttpStatusCode.PreconditionFailed;
         WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message;
         BusinessLogic.Common.Common common = new BusinessLogic.Common.Common();
         common.CreateErrorLog(UserId, "GetModuleQuestions", e.Message, 0);
     }
     return(null);
 }
コード例 #3
0
        public IActionResult Get(string email, string goalName)
        {
            try {
                Goal goal = GoalDataAccess.GetOne(email, goalName);

                if (goal == null)
                {
                    return(NotFound());
                }
                else
                {
                    return(new ObjectResult(goal));
                }
            }
            catch (Exception) {
                return(NotFound());
            }
        }
コード例 #4
0
        public IActionResult Get(string email)
        {
            try {
                List <Goal> goals = GoalDataAccess.GetByEmail(email);

                if (goals == null)
                {
                    return(NotFound());
                }
                else
                {
                    return(new ObjectResult(goals));
                }
            }
            catch (Exception) {
                return(NotFound());
            }
        }
コード例 #5
0
        public IActionResult Put(string email, string goalName, [FromBody] Goal goal)
        {
            var tmpGoal = GoalDataAccess.GetOne(email, goalName);

            if (tmpGoal == null)
            {
                return(NotFound());
            }
            else
            {
                if (GoalDataAccess.Update(goal))
                {
                    return(new OkObjectResult(GoalDataAccess.GetOne(email, goalName)));
                }
                else
                {
                    return(new BadRequestResult());
                }
            }
        }
コード例 #6
0
        public IActionResult Delete(string email, string goalName)
        {
            var goal = GoalDataAccess.GetOne(email, goalName);

            if (goal == null)
            {
                return(NotFound());
            }
            else
            {
                if (GoalDataAccess.Delete(email, goalName))
                {
                    return(new OkResult());
                }
                else
                {
                    return(new BadRequestResult());
                }
            }
        }
コード例 #7
0
        public IActionResult Patch(string email, string goalName, [FromBody] Goal goal)
        {
            var tmpGoal = GoalDataAccess.GetOne(email, goalName);

            if (tmpGoal == null)
            {
                return(NotFound());
            }
            else
            {
                goal.Email    = email;
                goal.GoalName = goalName;
                if (GoalDataAccess.Patch(goal))
                {
                    return(new OkObjectResult(GoalDataAccess.GetOne(email, goalName)));
                }
                else
                {
                    return(new BadRequestResult());
                }
            }
        }