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); }
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); }
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); }