public void UpdateSocialLink(AccountSocialLink updatesociallink, AccountSocialLink socialLink) { updatesociallink.Facebook = socialLink.Facebook; updatesociallink.Instagram = socialLink.Instagram; updatesociallink.Linkedin = socialLink.Linkedin; updatesociallink.Twitter = socialLink.Twitter; _context.SaveChanges(); }
public void RemoveFriend(int currentUserId, int friendId) { Friend friendship = _context.Friends.FirstOrDefault(f => (f.FromUserId == currentUserId && f.ToUserId == friendId) || f.FromUserId == friendId && f.ToUserId == currentUserId); if (friendship != null && friendship.StatusCode == FriendshipStatus.Accepted) { _context.Friends.Remove(friendship); _context.SaveChanges(); } }
public void Delete(Chat entity) { if (context.Entry(entity).State == EntityState.Detached) { context.Attach(entity); } context.Remove(entity); context.SaveChanges(); }
public Account Register(Account Account) { Account.Password = Crypto.HashPassword(Account.Password); Account.AddedDate = DateTime.Now; Account.ModifiedDate = DateTime.Now; Account.AddedBy = "System"; Account.ModifiedBy = "System"; _context.Accounts.Add(Account); _context.SaveChanges(); return(Account); }
//reset password public void ResetPassword(Account account) { account.ResetPasswordCode = new Random().Next(1, 999999).ToString("D6"); account.ForgetToken = Guid.NewGuid().ToString(); _context.SaveChanges(); var userFullname = account.Name + " " + account.Surname; var fromEmail = new MailAddress("*****@*****.**", "Messenger App"); var fromEmailPassword = "******"; var toEmail = new MailAddress(account.Email); var appeal = "Dear, " + userFullname + "! "; var subject = "Messenger Account Reset Password! "; var messageBody = "</br> " + "<div style=' background-color: #665dfe; padding: 20px 0px;'> " + "<h2 style='padding: 10px 30px; font-size: 22px; color: #fff;'>" + appeal + "Your request for a password reset has been accepted. " + "Use the <strong>Password Reset Code</strong> below to complete the operation and set a new password. </h2>" + "<p style='padding: 10px 30px; font-size: 17px; color: #fff; background-color: brown;'>" + "If this request was not made by you, " + "<a style='color: #fff!important; font-weght: bold;' href='#'>ignore this operation</a>" + ". </p>" + "<center><p style='display: inline-block; background-color: #28a745; font-weight: bold; color: #fff; padding: 10px; " + "text-align: center; text-decoration: none; border: 1px solid transparent; font-size: 22px; border-radius: 5px; " + "line-height: 1.5;' >Code: " + account.ResetPasswordCode + "</p></center>" + "</br><h3 style='margin: 0px; padding: 10px 30px; font-size: 15px; color: #fff;'>" + DateTime.Now.Year + " Messenger Application © by Elchin Ganbarov & Pervin Pashazade </h3>"; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromEmail.Address, fromEmailPassword) }; var message = new MailMessage(fromEmail, toEmail) { Subject = subject, Body = messageBody, IsBodyHtml = true }; smtp.Send(message); }
public void Delete(Message entity) { context.Remove(entity); context.SaveChanges(); }
public void Delete(UserChat entity) { context.UserChats.Remove(entity); context.SaveChanges(); }