public ActionResult DisenrollUser(Guid lunchId) { var user = UserRepository.GetUserByName(User.Identity.Name); var enrollment = EnrollmentRepository.Get(user.Id, lunchId); var success = EnrollmentRepository.TryDelete(enrollment); var lunch = LunchRepository.Get(lunchId); UpdateLunchInfoOnClients(lunch); return(Json(new { userEnrolled = !success, numberOfEnrollments = lunch.NumberOfEnrollments, numberOfPortions = lunch.NumberOfPortions })); }
public ActionResult EnrollUser(Guid lunchId, Guid?variation = null) { var user = UserRepository.GetUserByName(User.Identity.Name); var enrollment = new Enrollment() { EnrolledById = user.Id, EnrolledForLunchId = lunchId, EnrollmentDate = DateTime.Now, MealVariationId = variation }; var success = EnrollmentRepository.TryInsert(enrollment); var lunch = LunchRepository.Get(lunchId); UpdateLunchInfoOnClients(lunch); return(Json(new { userEnrolled = success, numberOfEnrollments = lunch.NumberOfEnrollments, numberOfPortions = lunch.NumberOfPortions })); }
public LunchModel Get(int id) { return(lunchRepo.Get(id).ToContract()); }