Exemplo n.º 1
0
        public async Task <Student> Delete(Student student)
        {
            if (!await StudentValidator.Delete(student))
            {
                return(student);
            }

            try
            {
                await UOW.Begin();

                await UOW.StudentRepository.Delete(student.Id);

                await UOW.Commit();

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

                throw new MessageException(ex);
            }
        }
Exemplo n.º 2
0
        public async Task <Student> Delete(Student student)
        {
            if (!await StudentValidator.Delete(student))
            {
                return(student);
            }

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

                    await UOW.Commit();
                }
                catch (Exception e)
                {
                    await UOW.Rollback();

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