public ActionResult Create() { var command = new AddDocumentCommand(); FillSocialMediaOptions(); return(View("Create", command)); }
private async Task SendCheckoutConfirmationMail(BookingDataModel booking) { TemplateDataModel template = await TemplateProvider.GetTemplateByName("slutafregningskvittering"); string mailText = TemplateProvider.MergeText(template.Text, booking); MailAddress to = new MailAddress(booking.ContactEMail, booking.ContactName); MailMessage message = new MailMessage { To = to, Subject = template.Subject, HtmlBody = mailText }; await MailDispatchService.DispatchAsync(message); byte[] mailBody = System.Text.Encoding.UTF8.GetBytes(message.HtmlBody); var addDcoumentCommand = new AddDocumentCommand { Title = message.Subject, MimeType = "text/html", Body = mailBody }; await CommandExecutor.ExecuteAsync(addDcoumentCommand); booking.AddDocument(message.Subject, addDcoumentCommand.OutputDocumentId); }
public void ReportChange() { _parent.ReportChange(); Notify("HasChanges"); AddDocumentCommand.RaiseCanExecuteChanged(); RemoveDocumentsCommand.RaiseCanExecuteChanged(); }
public ActionResult Create(Guid storeId) { var command = new AddDocumentCommand { StoreId = storeId }; FillSocialMediaOptions(); return(View("Create", command)); }
public ActionResult Create(AddDocumentCommand command) { if (!ModelState.IsValid) { return(View()); } var result = _commandBus.Send(command); ViewBag.Result = result; return(View()); }
public async Task ExecuteAsync(SendBookingMailCommand command, IExecutionContext executionContext) { PermissionValidationService.EnforceCustomEntityPermission <CustomEntityUpdatePermission>(BookingCustomEntityDefinition.DefinitionCode, executionContext.UserContext); using (var scope = DomainRepository.Transactions().CreateScope()) { BookingDataModel booking = await BookingProvider.GetBookingById(command.BookingId); await booking.AddLogEntry(CurrentUserProvider, $"Sendt: {command.Subject}."); byte[] mailBody = System.Text.Encoding.UTF8.GetBytes(command.Message); var addDcoumentCommand = new AddDocumentCommand { Title = command.Subject, MimeType = "text/html", Body = mailBody }; await CommandExecutor.ExecuteAsync(addDcoumentCommand); booking.AddDocument(command.Subject, addDcoumentCommand.OutputDocumentId); UpdateCustomEntityDraftVersionCommand updateCmd = new UpdateCustomEntityDraftVersionCommand { CustomEntityDefinitionCode = BookingCustomEntityDefinition.DefinitionCode, CustomEntityId = command.BookingId, Title = booking.MakeTitle(), Publish = true, Model = booking }; await DomainRepository.CustomEntities().Versions().UpdateDraftAsync(updateCmd); MailAddress to = new MailAddress(booking.ContactEMail, booking.ContactName); MailMessage message = new MailMessage { To = to, Subject = command.Subject, HtmlBody = command.Message }; // It is not really a good idea to contact a mail server during a transaction, but ... // 1) I really don't want the mail being registered in the database as "sent" if the mail sending fails. // 2) One can hope that the dispatcher simply adds the message to an outgoing mail queue. // (and, yes, sending mails may fail much later with an "unknown recipient" or similar) await MailDispatchService.DispatchAsync(message); await scope.CompleteAsync(); } }
private ShellViewModel() { documents = new ObservableCollection <EditorViewModel>(); AddDocumentCommand = ReactiveCommand.Create(); AddDocumentCommand.Subscribe(_ => { Documents.Add(new EditorViewModel()); }); GCCommand = ReactiveCommand.Create(); GCCommand.Subscribe(_ => { GC.Collect(); }); }
public ActionResult Create(AddDocumentCommand command) { if (!ModelState.IsValid) { FillSocialMediaOptions(); return(View("Create")); } var result = _commandBus.Send(command); if (!result.Success) { return(JsonMessage(result)); } SavePicture(AddAboutPicture(command), DocumentPicturePath); SavePicture(AddGuidePicture(command), DocumentPicturePath); return(JsonMessage(result)); }
private void RaiseCanExecuteChangedAllCommands() { AddDocumentCommand.RaiseCanExecuteChanged(); }
public async Task <IActionResult> Create([FromBody] AddDocumentCommand addDocumentCommand) { var id = await _mediator.Send(addDocumentCommand); return(Ok(id)); }