public async Task <IActionResult> PutBoard_Members(int id, Board_Members board_Members)
        {
            if (id != board_Members.Board_MembersId)
            {
                return(BadRequest());
            }

            _context.Entry(board_Members).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Board_MembersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutPermissions(int id, Permissions permissions)
        {
            if (id != permissions.PermissionsId)
            {
                return(BadRequest());
            }

            _context.Entry(permissions).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PermissionsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> PutTable(int id, Table table)
        {
            if (id != table.TableId)
            {
                return(BadRequest());
            }

            _context.Entry(table).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 4
0
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.UserId)
            {
                return(BadRequest());
            }

            _context.Entry(user).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 5
0
        public async Task <IActionResult> PutCard(int id, Card card)
        {
            if (id != card.CardId)
            {
                return(BadRequest());
            }

            _context.Entry(card).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CardExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 6
0
        public async Task <IActionResult> PutGroup(int id, Group @group)
        {
            if (id != @group.GroupId)
            {
                return(BadRequest());
            }

            _context.Entry(@group).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GroupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 7
0
        public async Task <ActionResult <Card> > PutCard(Guid id, Card card)
        {
            if (id != card.Id || card.Titulo == "" || card.Conteudo == "")
            {
                return(BadRequest());
            }

            _context.Entry(card).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CardExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            Console.WriteLine($"{DateTime.Now} - Card {id} - {card.Titulo} - Alterar");

            return(card);
        }
Esempio n. 8
0
        public async Task <ActionResult <TblKanbanList> > PostList([FromBody] TblKanbanList item)
        {
            item.UpdateTime = DateTime.Now;
            _context.KanbanLists.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(Get), new { id = item.Id }, item));
        }
Esempio n. 9
0
        public async Task <IActionResult> PatchUser(int id, [FromBody] PatchUserDTO dto)
        {
            var user = await _context.Users.FindAsync(id);

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

            user.Email = dto.IsFieldPresent(nameof(user.Email)) ? dto.Email : user.Email;

            await _context.SaveChangesAsync();

            return(NoContent());
        }
Esempio n. 10
0
        public async Task <IActionResult> PatchDesk(int id, [FromBody] PatchDeskDTO dto)
        {
            var desk = await _context.Desks.FindAsync(id);

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

            desk.Title       = dto.IsFieldPresent(nameof(desk.Title)) ? dto.Title : desk.Title;
            desk.Description = dto.IsFieldPresent(nameof(desk.Description)) ? dto.Description : desk.Description;

            await _context.SaveChangesAsync();

            return(NoContent());
        }
        public async Task <Board> CreateBoard(Board board)
        {
            _context.Boards.Add(board);
            var result = await _context.SaveChangesAsync();

            if (result > 0)
            {
                return(board);
            }
            throw new System.Exception("Could not save board to database.");
        }
 public async Task <bool> SaveChangesAsync()
 {
     return((await _context.SaveChangesAsync()) > 0);
 }