Пример #1
0
        private async Task <IServiceResult <StudentViewModel> > Delete(Student student)
        {
            var studentViewModel = _mapper.Map <StudentViewModel>(student);

            var userResult = await _userDeleter.Delete(student.UserId);

            if (!userResult.Successful())
            {
                return(ServiceResult <StudentViewModel> .Error(userResult.GetAggregatedErrors()));
            }

            return(ServiceResult <StudentViewModel> .Success(studentViewModel));
        }
Пример #2
0
        public async Task <IServiceResult <PromoterViewModel> > Delete(int id)
        {
            var promoter =
                await _context
                .Promoters
                .FirstOrDefaultAsync(p => p.Id == id);

            if (promoter == null)
            {
                return(ServiceResult <PromoterViewModel> .Error(
                           $"Promoter with id {id} does not exist"));
            }

            var promoterViewModel = _mapper.Map <PromoterViewModel>(promoter);

            var userResult = await _userDeleter.Delete(promoter.UserId);

            if (!userResult.Successful())
            {
                return(ServiceResult <PromoterViewModel> .Error(userResult.GetAggregatedErrors()));
            }

            return(ServiceResult <PromoterViewModel> .Success(promoterViewModel));
        }