示例#1
0
        public async Task <BaseResponseDto <MemberDto> > Handle(AddMemberRequest request, CancellationToken cancellationToken)
        {
            BaseResponseDto <MemberDto> response = new BaseResponseDto <MemberDto>();

            try
            {
                var addMember = new Member
                {
                    CreatedAt  = DateTime.Now,
                    ModifiedAt = DateTime.Now,
                    Classid    = request.Classid,
                    Userid     = request.Userid
                };
                await _repositoryWrapper.Member.Create(addMember);

                if (await _repositoryWrapper.SaveChangesAsync())
                {
                    response.Data = addMember.Adapt <MemberDto>();
                }
                else
                {
                    response.Errors.Add("Veri tabanı kayıt esnasında bir sorun oluştu.");
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.InnerException.Message);
                response.Errors.Add(ex.InnerException.Message);
                response.Errors.Add("Üye oluşturulurken bir hata oluştu.");
            }
            return(response);
        }