Ejemplo n.º 1
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());
            }
        }
Ejemplo n.º 2
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());
                }
            }
        }
Ejemplo n.º 3
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());
                }
            }
        }
Ejemplo n.º 4
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());
                }
            }
        }