示例#1
0
        public IActionResult Update(int id, [FromBody] Settingslist item)
        {
            if (item == null || item.UserId != id)
            {
                return(BadRequest());
            }

            var user = _context.UserDetails.FirstOrDefault(t => t.UserId == id);

            if (user == null)
            {
                return(NotFound());
            }

            user.FirstName    = item.FirstName;
            user.LastName     = item.LastName;
            user.PasswordHash = item.PasswordHash;
            user.PasswordSalt = item.PasswordSalt;
            user.PhotoUrl     = item.PhotoUrl;



            _context.UserDetails.Update(user);
            _context.SaveChanges();
            return(new NoContentResult());
        }
        public async Task <List <Settingslist> > GetById(int id)
        {
            Settingslist objectsettings = await _context.UserDetails.FirstOrDefaultAsync(ID => ID.UserId == id);

            List <Settingslist> settings = new List <Settingslist>();

            settings.Add(objectsettings);
            return(settings);
        }
        public IActionResult PhotoUpdate(int id, [FromBody] Settingslist item)
        {
            if (item == null || item.UserId != id)
            {
                return(BadRequest());
            }

            var user = _context.UserDetails.FirstOrDefault(t => t.UserId == id);

            if (user == null)
            {
                return(NotFound());
            }
            Console.WriteLine("reached patch in photo controller");
            user.UserId   = item.UserId;
            user.PhotoUrl = item.PhotoUrl;

            _context.UserDetails.Update(user);
            _context.SaveChanges();
            return(new NoContentResult());
        }
示例#4
0
 public async Task CreateAsync([FromBody] Settingslist item)
 {
     _context.UserDetails.Add(item);
     await _context.SaveChangesAsync();
 }