public ActionResult<Invitation> Create([FromBody] Invitation invitation, string userEmail) { Invitation inv = _invitationRepository.Create(invitation, userEmail); if (inv == null) return NotFound(); else return inv; }
public async Task <ActionResult> CreateInvitation(string email, Guid roleId, Guid?organizationId) { using (var txscope = new TransactionScope(TransactionScopeOption.RequiresNew)) { try { var activationCode = string.Empty; _invitationRepository.Create(roleId, organizationId, email, out activationCode); Context.SaveChanges(); Dictionary <string, string> values = new Dictionary <string, string>(); values.Add("[ActivationCode]", activationCode); MessageHelper.SendMessage(MessageTemplateTypes.RegistrationActivationCode, values, CurrentUserOrganizationID, email); //The Transaction will be completed txscope.Complete(); } catch (Exception ex) { LogHelper.WriteError(ex); } } return(RedirectToAction("Index")); }