public IActionResult Post([FromBody] Goal goal) { if (GoalDataAccess.Add(goal)) { return(Created($"/api/Goals/{goal.Email}", goal)); } else { return(new BadRequestResult()); } }
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); }
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()); } }
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()); } }
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()); } } }
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()); } } }
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()); } } }