コード例 #1
0
        public ServiceResponse <List <MailReadModel> > List(int page, int pageSize)
        {
            var response        = new ServiceResponse <List <MailReadModel> >();
            var mailConverter   = new MailConverter();
            var serviceResponse = _mailService.ListForUser(page, pageSize, CurrentUser.ID);

            if (serviceResponse.IsSuccessed)
            {
                response.Data = mailConverter.ConvertReadModel(mailConverter.Convert(serviceResponse.Data));
            }
            response.IsSuccessed = serviceResponse.IsSuccessed;
            return(response);
        }
コード例 #2
0
        public ServiceResponse <List <MailReadModel> > ListUnreadMails()
        {
            var response        = new ServiceResponse <List <MailReadModel> >();
            var serviceResponse = _mailService.ListUnreadMails(CurrentUser.ID);
            var mailConverter   = new MailConverter();

            if (serviceResponse.IsSuccessed)
            {
                response.Data = mailConverter.ConvertReadModel(mailConverter.Convert(serviceResponse.Data));
            }
            response.IsSuccessed = serviceResponse.IsSuccessed;
            return(response);
        }
コード例 #3
0
        public ServiceResponse <MailReadModel> Read(Guid guid)
        {
            var response = new ServiceResponse <MailReadModel>();
            var entity   = _mailService.Read(guid);

            if (entity.IsSuccessed)
            {
                var mailConverter = new MailConverter();
                var responseData  = mailConverter.Convert(entity.Data);
                responseData.FromUser = new UserConverter().Convert(_userService.Read(responseData.FromUserId).Data);
                responseData.ToUser   = new UserConverter().Convert(_userService.Read(responseData.ToUserId).Data);
                response.Data         = mailConverter.ConvertReadModel(responseData);
                if (!responseData.IsRead || responseData.ToUserId == CurrentUser.ID)
                {
                    responseData.IsRead = true;
                    var entityData = new MailConverter().Convert(responseData);
                    _mailService.Update(entityData);
                }
            }
            response.IsSuccessed = response.IsSuccessed;
            return(response);
        }