Esempio n. 1
0
        public object AddUser([FromBody] User user)
        {
            SHA1 sha1 = SHA1.Create();

            user.Password = GetString(sha1.ComputeHash(GetBytes(user.Password)));
            //user.Password = ToUnicode(user.Password);
            //user.FirstName = ToUnicode(user.FirstName);
            //user.LastName = ToUnicode(user.LastName);
            //user.Username = ToUnicode(user.Username);
            user.RegisterDate   = DateTime.Now;
            user.Storage        = 32;
            user.SharedSites    = "{\"Shared\": [],\"Accepted\": []}";
            user.AccountPicture = "";
            _context.User.Add(user);
            _context.SaveChanges();
            return(new { Success = true });
        }
Esempio n. 2
0
        public object DeleteAll()
        {
            var users = _context.User.Where(x => x.ID == x.ID);

            foreach (var user in users)
            {
                if (user.Email != "*****@*****.**")
                {
                    var sites = _context.Site.Where(x => x.UserID == user.ID);
                    foreach (var site in sites)
                    {
                        var components = _context.Component.Where(x => x.SiteID == site.ID);
                        foreach (var component in components)
                        {
                            _context.Component.Remove(component);
                        }
                        _context.Site.Remove(site);
                    }
                    _context.User.Remove(user);
                }
            }
            _context.SaveChanges();
            return(new { Success = true });
        }