Example #1
0
        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
            }));
        }
Example #2
0
        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
            }));
        }
Example #3
0
 public LunchModel Get(int id)
 {
     return(lunchRepo.Get(id).ToContract());
 }