Ejemplo n.º 1
0
        public void UpdateMailRead(int userID, MailReadUpdate mailRead)
        {
            UserMail userMail = _context.UserMails.Where(um => um.MailID == mailRead.MailID && um.UserID == userID).First();

            userMail.Read = mailRead.Read;
            _context.SaveChanges();
        }
Ejemplo n.º 2
0
        public void UpdateGroupName(GroupNameUpdate groupNameUpdate)
        {
            Group group = _context.Groups.Where(g => g.ID == groupNameUpdate.GroupID).FirstOrDefault();

            group.GroupName = groupNameUpdate.Name;
            _context.SaveChanges();
        }
Ejemplo n.º 3
0
        public IActionResult CreateMessage(Message message)
        {
            if ((!ModelState.IsValid) || message.Email == "" || message.Host == "" || message.Last == 0 || message.Msg == "")
            {
                return(BadRequest("Please check your data"));
            }

            _context.Messages.Add(message);
            _context.SaveChanges();
            return(Ok(message));
        }
Ejemplo n.º 4
0
        public void UpdateUserRole(UserRoleUpdate userRoleUpdate)
        {
            var user = _context.Users.First(u => u.Email == userRoleUpdate.Address);

            user.Role = _context.Roles.First(r => r.RoleName == userRoleUpdate.RoleName);
            _context.SaveChanges();
            if (userRoleUpdate.RoleName == "User" || userRoleUpdate.RoleName == "Admin")
            {
                _notificationService.SendNotification(new List <string> {
                    userRoleUpdate.Address
                }, "ActivatedAccount", false);
            }
            else if (userRoleUpdate.RoleName == "Banned")
            {
                _notificationService.SendNotification(new List <string> {
                    userRoleUpdate.Address
                }, "BannedAccount", false);
            }
        }