Ejemplo n.º 1
0
        public async Task <ActionResult <Lesson> > AddLesson(int adminId, NewLessonDto newLessonDto)
        {
            var createdBy = await _repo.GetUser(adminId);

            // if (createdBy.Id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            //     return Unauthorized();

            var lesson = _mapper.Map <Lesson>(newLessonDto);

            lesson.AdminId = adminId;
            // lesson.CategoryName = Lesson.Category.Tabulatury;

            _repo.Add(lesson);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            throw new Exception("Zapisanie lekcji nie powiodło się");
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <User> > UpdateUser(int userId, UserUpdateDto userUpdateDto)
        {
            var user = await _repo.GetUser(userId);

            // if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier)?.Value))
            //     return Unauthorized();
            userUpdateDto.BirthDate = userUpdateDto.BirthDate.AddDays(1);
            var updatedUser = _mapper.Map(userUpdateDto, user);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            throw new Exception("Zapisanie zmian nie powiodło się.");
        }