public async Task <ActionResult <Postit> > InsertNote(Postit note) { _context.Postit.Add(note); await _context.SaveChangesAsync(); return(note); //CreatedAtAction(nameof(note), new { Id = note.Postit_Id, }, note); }
public async Task <Postit> CreatePostit(int boardId) { WhiteboardItem board = await _context.Whiteboard.FirstOrDefaultAsync(x => x.Id == boardId); if (board == null) { return(null); } Postit note = new Postit(); var random = new Random(); note.WhiteboardId = boardId; note.Width = 200; note.Height = 166; note.PosX = random.Next(0, 100); note.PosY = random.Next(0, 100); note.IsCollapsed = false; int r = random.Next(150, 255); int g = random.Next(150, 255); int b = random.Next(150, 255); note.ColorCode = "rgba(" + r + "," + g + "," + b + ", 1)"; await _context.Postit.AddAsync(note); await _context.SaveChangesAsync(); return(note); }
public async Task <Postit> CopyPostit(int postitId, int boardId) { WhiteboardItem board = await _context.Whiteboard.FirstOrDefaultAsync(x => x.Id == boardId); Postit postit = await _context.Postit.FirstOrDefaultAsync(y => y.Id == postitId); if (board == null || postit == null) { return(null); } Postit newNote = new Postit(); newNote.WhiteboardId = board.Id; newNote.Content = postit.Content; newNote.Width = postit.Width; newNote.Height = postit.Height; newNote.PosX = postit.PosX; newNote.PosY = postit.PosY; newNote.IsCollapsed = postit.IsCollapsed; newNote.ColorCode = postit.ColorCode; await _context.Postit.AddAsync(newNote); await _context.SaveChangesAsync(); return(newNote); }
public async Task <Postit> Create(Postit postit) { await _ctx.Postits.AddAsync(postit); await _ctx.SaveChangesAsync(); return(postit); }
public async Task <IActionResult> UpdateNote(int Postit_Id, Postit note) { if (Postit_Id != note.Postit_Id) { return(BadRequest()); } _context.Entry(note).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <Postit> DeletePostit(int boardId, int postitId) { Postit note = await _context.Postit.FirstOrDefaultAsync(x => x.Id == postitId); if (note == null) { return(null); } _context.Postit.Remove(note); await _context.SaveChangesAsync(); return(null); }
public async Task <Postit> UpdatePostit(Postit postit) { // List<Postit> notes = await _context.Postit.ToListAsync(); // if (notes == null) { // return null; // } Postit note = await _context.Postit.FirstOrDefaultAsync(x => x.Id == postit.Id); note.Content = postit.Content; note.PosX = postit.PosX; note.PosY = postit.PosY; note.Width = postit.Width; note.Height = postit.Height; note.IsCollapsed = postit.IsCollapsed; note.WhiteboardId = postit.WhiteboardId; await _context.SaveChangesAsync(); return(note); }
public async Task Update(Postit postit) { var note = await GetById(postit.Id); if (note == null) { await _ctx.Postits.AddAsync(postit); await _ctx.SaveChangesAsync(); return; } note.Todo.Content = postit.Todo.Content; note.Todo.Title = postit.Todo.Title; note.Todo.Finished = postit.Todo.Finished; if (note.Color != postit.Color) { note.Color = postit.Color; } if (note.X != postit.X) { note.X = postit.X; } if (note.Y != postit.Y) { note.Y = postit.Y; } _ctx.Postits.Update(note); await _ctx.SaveChangesAsync(); }
public async Task <Postit> UpdatePostit(Postit postit) { return(await _repo.UpdatePostit(postit)); }