示例#1
0
        public async Task <Student> Update(Student student)
        {
            //student Id sẽ được gán bằng Id của thí sinh đang truy cập hệ thống
            student.Id = CurrentContext.StudentId;
            if (!await StudentValidator.Update(student))
            {
                return(student);
            }

            //Cập nhật thông tin thí sinh
            try
            {
                await UOW.Begin();

                await UOW.StudentRepository.Update(student);

                await UOW.Commit();

                return(await UOW.StudentRepository.Get(student.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                throw new MessageException(ex);
            }
        }
        public async Task <Student> Update(Student student)
        {
            if (!await StudentValidator.Update(student))
            {
                return(student);
            }

            using (UOW.Begin())
            {
                try
                {
                    await UOW.StudentRepository.Update(student);

                    await UOW.Commit();

                    return(await UOW.StudentRepository.Get(student.Id));
                }
                catch (Exception e)
                {
                    await UOW.Rollback();

                    student.AddError(nameof(StudentService), nameof(Update), CommonEnum.ErrorCode.SystemError);
                    return(student);
                }
            }
        }