public async Task <Unit> Handle(DeleteStudentCommand request, CancellationToken cancellationToken)
        {
            var entity = await _context.Students
                         .FindAsync(request.Id);

            if (entity == null)
            {
                throw new NotFoundException(nameof(Student), request.Id);
            }

            _context.Students.Remove(entity);

            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(CreateStudentCommand request, CancellationToken cancellationToken)
        {
            var entity = new Student
            {
                Name       = request.Name,
                Surname    = request.Surname,
                Patronymic = request.Patronymic,
                Gender     = request.Gender.Value,
                Nickname   = request.Nickname
            };

            _context.Students.Add(entity);

            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(UpdateStudentCommand request, CancellationToken cancellationToken)
        {
            var entity = await _context.Students.SingleOrDefaultAsync(s => s.Id == request.Id, cancellationToken);

            if (entity == null)
            {
                throw new NotFoundException(nameof(Student), request.Id);
            }

            entity.Name       = request.Name;
            entity.Surname    = request.Surname;
            entity.Patronymic = request.Patronymic;
            entity.Gender     = request.Gender.Value;
            entity.Nickname   = request.Nickname;

            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }