Exemplo n.º 1
0
        // ReSharper disable once UnusedMember.Global
        public void Delete(LessonDeleteRequest request)
        {
            Guard.IsTrue(id => 0 < id, request.Id);
            Guard.AgainstEmpty(request.Provider);
            Guard.AgainstEmpty(request.ProviderId);
            var existingUser = UserHelpers.GetExistingUser(request, UserRepository);

            Guard.IsTrue(eu => eu.IsNew == false, existingUser);

            var lesson = LessonRepository.Find(request.Id);

            if (lesson == null)
            {
                return;
            }

            if (existingUser.IsTeacher == false || request.Provider != lesson.Provider || request.ProviderId != lesson.ProviderId)
            {
                throw new HttpError(HttpStatusCode.Unauthorized, "Unauthorized");
            }

            if (lesson.IsDeleted)
            {
                return;
            }

            LessonRepository.DeleteLesson(request.Id);
        }
Exemplo n.º 2
0
 public bool DeleteLesson(long id)
 {
     return(lsrepository.DeleteLesson(id));
 }