/// <summary> /// Saves email addresses of recipients to the database. /// And returns his ids that stored in DB. /// </summary> /// <param name="recipientMails">Email addresses of recipients</param> /// <returns>List recipients with id and mail</returns> private async Task <IEnumerable <Recipient> > SaveRecipients(IEnumerable <string> recipientMails) { var recipients = new List <Recipient>(); bool isNewAdded = false; foreach (string recipientMail in recipientMails) { Recipient recipient = await _recipientRepository.GetByEmail(recipientMail); if (recipient == null) { recipient = _recipientRepository.Add(new Recipient { Email = recipientMail }); isNewAdded = true; } recipients.Add(recipient); } if (isNewAdded) { await _recipientRepository.UnitOfWork.SaveChangesAsync(); } return(recipients); }
private Recipient CreateNewRecipient() { var recipient = new Recipient(); _recipientRepository.Add(recipient); return(recipient); }
public Recipient CreateNewRecipient(string name, string phoneNo, string email) { var recipient = Recipient.Create(name, phoneNo, email); recipient = recipientRepository.Add(recipient); PersistenceContext.SaveChanges(); return(recipient); }
public async Task <int> Add(RecipientDto recipient) { await _validator.ValidateForAdding(recipient); var recipientEntity = _mapper.Map <Recipient>(recipient); return(await _recipientRepository.Add(recipientEntity)); }
public ActionResult Create([Bind(Include = "Id,MarketPlaceIdentifier,MarketPlaceAssignedPolicyNumber,PolicyIssuerName,RecipientFirstName,RecipientMiddleName,RecipientLastName,RecipientFirstSSN,RecipientDob,RecipientSpouseFirstName,RecipientSpouseMiddleName,RecipientSpouseLastName,RecipientSpouseSSN,RecipientSpouseDob,CreatedDate,CreatedBy,IsActiveRecord,DeactivatedDate,DeactivatedBy")] Recipient recipient) { if (ModelState.IsValid) { _recipientRepository.Add(recipient); _recipientRepository.Save(); return(RedirectToAction("Index")); } return(View(recipient)); }
private void AddRecipient() { var name = _view.RecipientName; var id = _view.Id; if (_view.IsCreateChannel) { _recipientRepository.Add(new Channel(name, id)); } else if (_view.IsCreateGroup) { _recipientRepository.Add(new Group(name, id)); } else if (_view.IsCreatePhone) { _recipientRepository.Add(new Person(name, id)); } else { _view.ShowMessage("Выберите тип получателя"); } _view.Update(_recipientRepository.Recipients); }