public void Add(SaveContentMessage message) { var content = new Content(); var attachment = new Attachment(); attachment.Name = message.FileName; attachment.File = message.File; content.Attachment = attachment; _contentRepository.Add(content); _contentRepository.SaveChanges(); }
public void SetContent(int id, SetAdvertisementContentMessage message) { var advertisement = _advertisementRepository.Get(id); if (advertisement == null) throw new Exception("Anúncio não encontrado"); if (advertisement.Content != null && advertisement.Status == Domain.AdvertisementStatus.PendingContentApproval) throw new Exception("Esse anúncio conteúdo atribuído pendente de aprovação"); if (advertisement.Content != null && advertisement.Status != Domain.AdvertisementStatus.PendingContentDispatch) throw new Exception("Esse anúncio possui conteúdo aprovado"); var attachment = new Attachment(); attachment.File = message.File; attachment.Name = message.FileName; advertisement.Content = attachment; advertisement.Status = AdvertisementStatus.PendingContentApproval; _advertisementRepository.SaveChanges(); }