public async Task <ActionResult <Vacation> > PostVacation([FromBody] Vacation newItem)
        {
            var newVac = new Vacation {
                User = newItem.User, Location = newItem.Location, Startdate = newItem.Startdate, Isactive = true
            };

            _context.Vacation.Add(newVac);
            await _context.SaveChangesAsync();

            return(Ok(newVac));
        }
示例#2
0
        public async Task <ActionResult <Users> > RegisterUser([FromBody] Users newUser)
        {
            var user = from a in _context.Users
                       where a.Username == newUser.Username
                       select a;

            if (user.Any())
            {
                return(Conflict());
            }

            newUser.Joindate = DateTime.UtcNow.Date;
            _context.Users.Add(newUser);
            await _context.SaveChangesAsync();

            return(Ok(user));
        }