public void RemoveStroke([FromBody] Guid id) { Stroke stroke = db.Strokes.FirstOrDefault(s => s.Id == id); if (stroke == null) { return; } List <string> userIds = stroke.Board.Room.Users.Select(u => u.Id).ToList(); db.Strokes.Remove(stroke); db.SaveChanges(); PaintHub.RemoveStroke(userIds, id); }
public Guid AddStroke(AddStrokeData data) { Stroke s = new Stroke() { Id = Guid.NewGuid(), BoardId = data.BoardId, Data = data.Data }; db.Strokes.Add(s); db.SaveChanges(); List <string> userIds = db.Boards.First(b => b.Id == data.BoardId).Room.Users.Select(u => u.Id).ToList(); PaintHub.AddStroke(userIds, new StrokeData() { Id = s.Id, Data = data.Data, BoardId = data.BoardId }); return(s.Id); }