public List <CompletedChore> GetChoreItems([FromBody] GetChoreItemsRequestObject requestObject) { ProMaUser user = DataController.LoggedInUser; if (user == null) { throw new NotLoggedInException(); } DateTime dayForRequest = new DateTime(requestObject.year, requestObject.month, requestObject.day).Date; List <CompletedChore> returnThis = CompletedChoreHandler.GetChoreItemsForDateAndUser(user.UserId, dayForRequest); // we need to hydrate the data appropriately foreach (CompletedChore curChore in returnThis) { curChore.SharedChore = SharedChoreHandler.GetSharedChore(curChore.SharedChoreId); if (curChore.UserId.HasValue) { curChore.CompletedUser = ProMaUserHandler.GetUser(curChore.UserId.Value); } curChore.SharedChore.Membership = SharedChoreMembershipHandler.GetSharedChoreMembership(curChore.SharedChoreId, user.UserId); // find the last completed version of this chore // we only need to do this if this chore isn't complete, because it won't be displayed in the ui otherwise if (!curChore.Completed) { CompletedChore lastCompletion = CompletedChoreHandler.GetPreviousCompletedChore(curChore); if (lastCompletion != null) { curChore.LastDoneUser = ProMaUserHandler.GetUser(lastCompletion.UserId.Value); curChore.LastDoneTime = lastCompletion.ChoreDate; } } } return(returnThis.ToList()); }
public void SaveChoreAlert([FromBody] SaveChoreAlertRequestObject requestObject) { ProMaUser user = DataController.LoggedInUser; if (user == null) { throw new NotLoggedInException(); } SharedChoreMembership toUpdate = SharedChoreMembershipHandler.GetSharedChoreMembership(requestObject.choreId, user.UserId); if (requestObject.alertHour == -1) { toUpdate.AlertHour = null; toUpdate.AlertMinute = null; } else { toUpdate.AlertHour = requestObject.alertHour; toUpdate.AlertMinute = requestObject.alertMinute; } SharedChoreMembershipHandler.UpdateSharedChoreMembership(toUpdate); }