Пример #1
0
        public async Task <IActionResult> CreatePost([FromBody] Posts post)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            post.CreationDate = DateTime.Now;

            await _context.Posts.AddAsync(post);

            await _context.SaveChangesAsync();

            return(Ok(post));
        }
        public async Task <IActionResult> GivePermission([FromBody] AppUser appUser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                _context.User.Update(appUser);
                await _context.SaveChangesAsync();
            }

            catch (DbUpdateConcurrencyException)
            {
                return(NotFound());
            }

            return(NoContent());
        }