public async Task <ActionResult> Login([FromBody] Users _user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (_user.Password != "1234")
            {
                return(BadRequest("Forkert brugernavn eller adgangkode"));
            }

            Users user = _context.Users.FirstOrDefault(x => x.Name == _user.Name);

            user.Counter++;

            user.LastLogin = DateTime.Now;

            await _context.SaveChangesAsync();

            return(Ok(user));
        }
Example #2
0
 //Asynkront kald
 public async Task Post([FromBody] GroceryTable value)
 {
     _context.GroceryTable.Add(value);
     await _context.SaveChangesAsync();
 }