public virtual ActionResult Create(SenderModel model) { if (string.IsNullOrWhiteSpace(model.Authentication.NewPassword)) { ModelState.AddModelError("NewPassword", Validation.EmplyPassword); } try { if (ModelState.IsValid) { var id = _senders.Add(model); return(RedirectToAction(MVC.Sender.Edit(id))); } } catch (DublicateLoginException) { ModelState.AddModelError("Authentication.Login", Validation.LoginExists); } BindBag(); return(View()); }
private async Task AddSender() { if (SenderEmail != null && SenderPassword != null) { var newSender = new Sender() { Email = SenderEmail, Password = PasswordCoding.Encrypt(SenderPassword) }; _senderService.Add(newSender); Senders = new ObservableCollection <Sender>(new ObservableCollection <Sender>(_senderService.GetAll().Select(x => x = new Sender() { Id = x.Id, Email = x.Email, Password = PasswordCoding.Decrypt(x.Password) }))); Messenger.Default.Send(newSender); } }