示例#1
0
        public async Task <Guid> CreateNew(StudentCreateModel newStudent)
        {
            var student = Domain.Entities.Student.Create(newStudent.FirstName, newStudent.LastName,
                                                         newStudent.Email, newStudent.Password, newStudent.Group, newStudent.Year);

            await writeRepository.AddNewAsync(student);

            await writeRepository.SaveAsync();

            return(student.Id);
        }
示例#2
0
        public async Task <Guid> Update(Guid id, StudentCreateModel updatedStudent)
        {
            var exist = await readRepository.FindByIdAsync <Domain.Entities.Student>(id);

            if (exist != null)
            {
                exist.Update(updatedStudent.FirstName, updatedStudent.LastName,
                             updatedStudent.Email, updatedStudent.Password, updatedStudent.Group, updatedStudent.Year);
                await writeRepository.UpdateAsync(id, exist);

                await writeRepository.SaveAsync();
            }
            return(exist.Id);
        }