private void SendEmail(InviteModel mailModel) { //konfiguracja i autoryzacja ze skrzynką mailowa var smtpClient = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, UseDefaultCredentials = true, Credentials = new NetworkCredential("*****@*****.**", "!QAZ2wsx#EDC") }; //tworzenie nowej wiadomosci email var mailMessage = new MailMessage { Sender = new MailAddress("*****@*****.**"), From = new MailAddress("*****@*****.**"), To = { mailModel.Email }, Subject = "temat maila" , Body = "tresc maila", IsBodyHtml = true }; //wyslanie email smtpClient.Send(mailMessage); }
public InviteModel getInvite(int token) { using (SqlConnection sqlConnection = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand("sp_UserGetInvitesByToken", sqlConnection)) { try { sqlConnection.Open(); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Token", token); SqlDataReader rdr = command.ExecuteReader(); InviteModel invite = new InviteModel(); while (rdr.Read()) { invite.Id = Convert.ToInt32(rdr["Id"]); invite.StudentId = rdr["StudentId"].ToString(); invite.TeacherId = rdr["TeacherId"].ToString(); invite.SubjectId = Convert.ToInt32(rdr["SubjectId"]); invite.Accepted = Convert.ToBoolean(rdr["Accepted"]); invite.CreateDate = Convert.ToDateTime(rdr["CreateDate"]); } return(invite); } catch (Exception ex) { throw ex; } } } }
public async void AddPendingInvite(InviteModel invite) { var dispatcher = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { //check if the user already has an invite for this session if (ObservablePendingInvites.FirstOrDefault(n => n.UserGuid == invite.UserGuid) == null) { invite.OnAccept = new RelayCommand(async() => { //do the signalR join session command. ObservablePendingInvites.Remove(invite); await MultiplayerHubProxy.Instance.JoinFriend(invite.UserGuid); }); invite.OnDecline = new RelayCommand(() => { //remove this object from the Observable list ObservablePendingInvites.Remove(invite); }); ObservablePendingInvites.Add(invite); } }); }
public async Task <Response <InviteDTO> > CreateInvite(string email, Guid entityId, InviteEntityType inviteEntityType, Guid authorId, string code = null) { if (string.IsNullOrEmpty(code)) { code = CodeHelper.GenerateCodeAsGuid(); } var invite = new InviteModel { Email = email, IsDeleted = false, IsSent = false, CreatedDate = DateTime.UtcNow, Code = code, EntityId = entityId, EntityType = inviteEntityType, CreatorId = authorId }; invite = await _repository.CreateInvite(invite); var mappedInvite = _mapper.Map <InviteDTO>(invite); return(new Response <InviteDTO> { Data = mappedInvite }); }
internal InviteViewModel(InviteModel model) { this.model = model; model.UpdateStatusMessage += model_UpdateStatusMessage; IsTextblockVisible = Visibility.Hidden; InviteCommand = new DelegateCommand(OnInvite); }
public async Task <ActionResult> Invite(InviteModel model) { if (ModelState.IsValid) { var user = _userManager.FindByName(model.Inviter); if (user != null) { var member = await _appRepo.GetMemberByIdentityIdAsync(user.Id); var invite = await _appRepo.InsertInviteAsync(new Invite() { InviteeEmail = model.Invitee, Inviter = user.UserName, CreateDate = DateTime.Now }); string subject = "Lunch Generator - Registration Invite"; string msg = $"You have been invited by {member.FirstName} {member.LastName} to join the lunch generator community."; msg += Environment.NewLine; msg += $"Click <a href='{Url.Action("Register", "Account", new { inviteToken = invite.ID, email = invite.InviteeEmail }, Request.Url.Scheme)}'>here</a> to register your account."; await _emailService.SendEmail(invite.InviteeEmail, subject, msg); return(RedirectToAction("Index", "Home")); } } return(View(model)); }
public async Task <InviteModel> CreateInvite(InviteModel entity) { _context.Invites.Add(entity); await _context.SaveChangesAsync(); return(entity); }
/// <summary> /// Generates the invite menu item. /// </summary> /// <returns></returns> private MenuItem GenerateInviteMenuItem() { var item = new MenuItem(); item.Header = Resources.InviteViewMenuTitle; var isEnabled = startupParams.AuthProvider != null; item.IsEnabled = isEnabled; item.Click += (sender, args) => { var model = new InviteModel(startupParams.AuthProvider); model.MessageLogged += this.OnMessageLogged; var viewModel = new InviteViewModel(model); var view = new InviteView(viewModel) { Owner = loadedParams.DynamoWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner }; view.ShowDialog(); model.MessageLogged -= this.OnMessageLogged; }; return(item); }
public ActionResult AddSubject(int subject, List <int> categoryId, string topicName, string description) { InviteModel newInvite = new InviteModel(); newInvite.TeacherId = null; newInvite.StudentId = User.Identity.GetUserId(); newInvite.Type = 1; newInvite.SubjectId = Convert.ToInt32(subject); int token = newInvite.Save(); if (token == -55) { throw new HttpException(404, "Some description"); } else { ResearchTopics topic = new ResearchTopics(); topic.Topic = topicName; topic.SubjectId = subject; topic.ShortDescription = description; topic.UserId = User.Identity.GetUserId(); topic.ResearchIds = categoryId; topic.Save(); foreach (int id in categoryId) { MailSender(id, subject); } } return(null); }
public async Task <ActionResult <InviteModel> > GetAsync() { var invite = new InviteModel(); using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue( _config.GetValue <string>("MeuIDCredentials:ApiToken")); var opportunity = new { opportunityId = _config.GetValue <string>("MeuIDCredentials:OpportunityId") }; var opportunityContent = new StringContent( JsonSerializer.Serialize(opportunity), Encoding.UTF8, "application/json"); using (var response = await httpClient.PostAsync( "https://api-v3.idwall.co/meuid/invites/opportunity", opportunityContent)) { var responseBody = await response.Content.ReadAsStringAsync(); invite = JsonSerializer.Deserialize <InviteModel>(responseBody); } } return(invite); }
public void UpSertInviteInfo(InviteModel model) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db))) { var p = new DynamicParameters(); if (model.Id == 0) { p.Add("@EventId", model.Event.Id); p.Add("@ClientId", model.Client.Id); } else { p.Add("@EventId", 0); p.Add("@ClientId", 0); } p.Add("@InviteApproved", model.InviteApproved); p.Add("@EmailSentDate", model.EmailSentDate); p.Add("@ClientAttending", model.ClientAttending); p.Add("@PlacesReserved", model.PlacesReserved); p.Add("@id", model.Id, dbType: DbType.Int32, direction: ParameterDirection.InputOutput); connection.Execute("dbo.spUpSertInvitationInfo_ByInviteId", p, commandType: CommandType.StoredProcedure); model.Id = p.Get <int>("@id"); } }
public IActionResult Index(InviteModel obj) { ViewBag.ShowLinkbtn = false; var uri = "/macros/s/AKfycbwilW4_LJrUVzziROPO6gdL3wM8cWnN-hke729NaQ67_vSfG_g/exec"; if (obj.Password == "20moola20") { ViewBag.ShowLinkbtn = true; var client = new RestClient("https://script.google.com"); var request = new RestRequest(uri, Method.POST); request.AddJsonBody(new { action = "get_stats" }); IRestResponse response = client.Execute(request); var content = response.Content; Dictionary <string, object> statistics = JsonConvert.DeserializeObject <Dictionary <string, object> >(content); var data = JsonConvert.SerializeObject(statistics["description"]); var datas = JsonConvert.DeserializeObject <Statistics>(data); ViewBag.TotalLinkGenerated = datas.total_links; ViewBag.TotalNotRegistered = datas.total_not_registered; ViewBag.TotalRegistered = datas.total_registered; } return(View()); }
internal RestInvite(RestDiscordClient client, InviteModel model) : base(client) { Code = model.Code; Guild = new RestGuild(client, model.Guild); model.Channel.GuildId = model.Guild.Id; Channel = RestChannel.Create(client, model.Channel); Update(model); }
public ActionResult InviteGuest(InviteModel model) { if (ModelState.IsValid) { SendEmail(model); return(View("Thanks", model)); } return(View("InviteGuest", model)); }
public ActionResult Invite() { var model = new InviteModel() { Inviter = HttpContext.User.Identity.Name }; return(View(model)); }
public void Startup(ViewStartupParams p) { publishModel = new PublishModel(p.AuthProvider, p.CustomNodeManager); publishViewModel = new PublishViewModel(publishModel); inviteModel = new InviteModel(p.AuthProvider); inviteModel.MessageLogged += this.OnMessageLogged; inviteViewModel = new InviteViewModel(inviteModel); }
public ActionResult InviteGuest(InviteModel model) { if (ModelState.IsValid) // sprawdza czy cały model się waliduje { SendEmail(model); return View("Thanks", model); } return View("Index", model); }
internal RestInviteMetadata(RestInvite invite, InviteModel model) { Invite = invite; Inviter = new RestUser(Invite.Client, model.Inviter); MaxUses = model.MaxUses; MaxAge = TimeSpan.FromSeconds(model.MaxAge); IsTemporaryMembership = model.Temporary; CreatedAt = model.CreatedAt; Update(model); }
public static InviteLogicModel ToLogicModel(this InviteModel invite) { return(invite == null ? null : new InviteLogicModel { Id = invite.Id, InviteEmail = invite.InviteEmail, IsRegister = invite.IsRegister, Project = invite.Project.ToLogicModel(), User = invite.User.ToLogicModel() }); }
public static InviteModel GetOrganizationOneUserOneInviteModel() { var model = new InviteModel(); model.OrganizationUid = OrganizationOneUid; model.Email = OrganizationOneUserOneEmail; model.FirstName = StringOne; model.LastName = StringTwo; return(model); }
public static void AddToShortList(DataGridView dgv) { foreach (DataGridViewRow dgvRow in dgv.SelectedRows) { InviteModel selectedInvite = (InviteModel)dgvRow.Tag; GlobalConfig.Connection.UpSertInviteInfo(selectedInvite); dgv.Rows.RemoveAt(dgvRow.Index); } }
public async Task Invite_POST_InvalidModel() { // arrange var model = new InviteModel(); // act var result = await SystemUnderTest.Invite(model); // assert AssertInputErrorMessagesOfView(result, model); }
public static List <InviteModel> FindUserEvents(string email) { InviteModel data = new InviteModel { UserEmail = email, }; string sql = @"select UserEmail, EventId, InviteStatus from dbo.UserEvents where (UserEmail = @UserEmail);"; return(SqlDataAccess.FindItems(sql, data)); }
public JsonResult AcceptRequest(int id, int status) { try { InviteModel.SaveStatusStudent(id, Convert.ToBoolean(status)); return(Json(string.Format("Your request has been {0}", Convert.ToBoolean(status) ? "accepted" : "declined"))); } catch (Exception ex) { return(Json(string.Format("An error occured please refresh the page"))); } }
public static void InvitesRejected(DataGridView dgv) { foreach (DataGridViewRow dgvRow in dgv.SelectedRows) { InviteModel selectedInvite = (InviteModel)dgvRow.Tag; selectedInvite.ClientAttending = false; GlobalConfig.Connection.UpSertInviteInfo(selectedInvite); dgv.Rows.RemoveAt(dgvRow.Index); } }
public ActionResult Requests(int t)//t=token { //show view where you need to accept or decline var invite = InviteModel.GetInvite(t); if (!invite.TeacherId.Equals(User.Identity.GetUserId()) || invite.Accepted) { return(RedirectToAction("Index", "Home")); } ViewBag.Inviter = new UserProfile(invite.StudentId); return(View(invite)); }
public JsonResult Invite(InviteModel model) { var currentUser = _securityHelper.CurrentUser; if (!_securableRepo.BlogsUserIsAdminOf(_blogRepo, currentUser.Id).Any(b => b.AuthorSecurableId == model.SecurableId)) { throw new HttpException(403, "Not Authorised"); } _invitationService.Invite(model.SecurableId, model.Email, currentUser.FullName()); return(Json(true)); }
public void UpdateInvite(InviteModel model) { var inviteEntity = this.inviteRepository.GetSingle(x => x.Id == model.Id); if (inviteEntity == null) { throw new Exception("Not found"); } this.mapper.Map(model, inviteEntity); this.inviteRepository.Save(); }
public static int Accept_Inv(string eventid, string email) { InviteModel data = new InviteModel { UserEmail = email, EventID = eventid, InviteStatus = "accepted" }; string sql = @"UPDATE dbo.UserEvents set InviteStatus = @InviteStatus WHERE UserEmail = @UserEmail and EventId = @EventID "; return(SqlDataAccess.SaveData(sql, data)); }
public static List <InviteModel> FindParticipants(string eventid) { InviteModel data = new InviteModel { EventID = eventid, InviteStatus = "accepted" }; string sql = @"select UserEmail, EventId, InviteStatus from dbo.UserEvents where EventId = @EventID and InviteStatus = @InviteStatus;"; return(SqlDataAccess.FindItems(sql, data)); }