Пример #1
0
 public void New(Message msg, MaildbContext context, ApplicationUser appUser)
 {
     msg.MailDate = DateTime.Now;
     msg.MailFrom = appUser.Email;
     context.Messages.Add(msg);
     context.SaveChanges();
 }
Пример #2
0
 public void DeleteFriend(string friendName)
 {
     using (var _context = new MaildbContext())
     {
         var friend = _context.ChatFriends.Single(c => c.Friend == friendName || c.FriendUserName == friendName);
         _context.ChatFriends.Remove(friend);
         _context.SaveChanges();
         Clients.Caller.friendsToList(CreateFriendsList(Context.User.Identity.Name, _context));
     }
 }
Пример #3
0
 public void Delete(MaildbContext _context, string[] rows)
 {
     if (rows != null)
     {
         foreach (var row in rows)
         {
             int id     = Decode(row);
             var delRow = _context.Messages.First(c => c.ID == id);
             _context.Messages.Remove(delRow);
         }
         _context.SaveChanges();
     }
 }
Пример #4
0
        public void AddFriend(string friendName)
        {
            ChatFriend      chtFr  = new ChatFriend();
            var             me     = Context.User.Identity.Name;
            ApplicationUser friend = new ApplicationUser();

            using (var _context = new MaildbContext())
            {
                var appUser = _context.Users.First(c => c.Email == me || c.UserName == me);
                friend = _context.Users.First(c => c.Email == friendName || c.UserName == friendName);
                chtFr.ApplicationUser = appUser;
                chtFr.Friend          = friend.Email;
                chtFr.FriendUserName  = friend.UserName;
                _context.ChatFriends.Add(chtFr);
                _context.SaveChanges();
                Clients.Caller.friendsToList(CreateFriendsList(me, _context));
            }
        }