private IBoardContext InitialiseTestBoardContext(IGameConfiguration _gameConfiguration) { var _boardContext = new BoardContext(); _boardContext.Height = _gameConfiguration.Height; _boardContext.Width = _gameConfiguration.Width; _boardContext.LoopEdges = _gameConfiguration.LoopEdges; const int livecellseed = 2; var counter = 0; var tmpBoard = new bool[_boardContext.Width, _boardContext.Height]; for (int y = 0; y < _boardContext.Height; y++) { for (int x = 0; x < _boardContext.Width; x++) { tmpBoard[x, y] = counter++ == livecellseed; if (counter > livecellseed) { counter = 0; } } } _boardContext.GameBoard = tmpBoard; return(_boardContext); }
public Announcement Get(int id) { using (var context = new BoardContext()) { return(context.Announcments.Single(a => a.Id == id)); } }
public int GetRep(User user) { using (var context = new BoardContext()) { return(context.Reputations.Count(a => a.Receiver.Id == user.Id)); } }
public void Handle(MoveTaskCommand message) { using (var ctx = new BoardContext()) { Board board = ctx.Boards.FirstOrDefault(b => b.Id == message.BoardId); if (message.SourceListId != message.DestinationListId) { List source = board.Lists.First(l => l.Id == message.SourceListId); Task task = source.Tasks.First(t => t.Id == message.TaskId); List destintation = board.Lists.First(l => l.Id == message.DestinationListId); destintation.Tasks = destintation.Tasks.OrderBy(t => t.Order).ToList(); destintation.InsertTask(message.TargetIndex, task); source.Tasks.Remove(task); OrderTasks(source); OrderTasks(destintation); } else { List source = board.Lists.First(l => l.Id == message.SourceListId); Task task = source.Tasks.First(t => t.Id == message.TaskId); source.Tasks.Remove(task); source.InsertTask(message.TargetIndex, task); OrderTasks(source); } ctx.SaveChanges(); } }
public RepairCaseRepository(BoardContext context, WorkerRepository workerRepository, EquipmentRepository equipmentRepository) { _context = context; _workerRepository = workerRepository; _equipmentRepository = equipmentRepository; }
/// <summary> /// Creates a new instance of the <see cref="Board"/> object. /// </summary> /// <param name="id">The board's ID.</param> /// <param name="auth">(Optional) Custom authorization parameters. When not provided, /// <see cref="TrelloAuthorization.Default"/> will be used.</param> public Board(string id, TrelloAuthorization auth = null) { Auth = auth; _context = new BoardContext(id, auth); _context.Synchronized += Synchronized; Id = id; Actions = new ReadOnlyActionCollection(typeof(Board), () => Id, auth); Cards = new ReadOnlyCardCollection(typeof(Board), () => Id, auth); _description = new Field <string>(_context, nameof(Description)); _isClosed = new Field <bool?>(_context, nameof(IsClosed)); _isClosed.AddRule(NullableHasValueRule <bool> .Instance); _isSubscribed = new Field <bool?>(_context, nameof(IsSubscribed)); _isSubscribed.AddRule(NullableHasValueRule <bool> .Instance); Labels = new BoardLabelCollection(() => Id, auth); Lists = new ListCollection(() => Id, auth); Members = new ReadOnlyMemberCollection(EntityRequestType.Board_Read_Members, () => Id, auth); Memberships = new BoardMembershipCollection(() => Id, auth); _name = new Field <string>(_context, nameof(Name)); _name.AddRule(NotNullOrWhiteSpaceRule.Instance); _organization = new Field <Organization>(_context, nameof(Organization)); PowerUps = new ReadOnlyPowerUpCollection(() => Id, auth); PowerUpData = new ReadOnlyPowerUpDataCollection(EntityRequestType.Board_Read_PowerUpData, () => Id, auth); Preferences = new BoardPreferences(_context.BoardPreferencesContext); PersonalPreferences = new BoardPersonalPreferences(Id, auth); _url = new Field <string>(_context, nameof(Url)); TrelloConfiguration.Cache.Add(this); }
public static Tuple <bool, string> registerProcess(IFormCollection form) { string username = form["username"]; string password = form["password"]; string confirmPassword = form["confirm_password"]; var db = new BoardContext(); if (password != confirmPassword) { return(new Tuple <bool, string>(false, "Passwords are different")); } else if (db.Users.Any(x => x.username == username)) { return(new Tuple <bool, string>(false, "Username already exists")); } // Password encryption password = crypto(password); // Register Action User newUser = new User(username, password); newUser.token = tokenGenerator(newUser); db.Add(newUser); db.SaveChanges(); return(new Tuple <bool, string>(true, "Register with Success!")); }
public List <Post> Get(Channel channel) { using (var context = new BoardContext()) { return(context.Posts.Include(p => p.Channel).Include(p => p.User).Where(p => p.Channel.Id == channel.Id).OrderByDescending(p => p.Date).ToList()); } }
public List <Announcement> Get() { using (var context = new BoardContext()) { return(context.Announcments.ToList()); } }
public List <Attachment> Get(Post post) { using (var context = new BoardContext()) { return(context.Attachments.Where(a => a.Post.Id == post.Id).ToList()); } }
/// <summary> /// Creates a new instance of the <see cref="Board"/> object. /// </summary> /// <param name="id">The board's ID.</param> /// <param name="auth">(Optional) Custom authorization parameters. When not provided, <see cref="TrelloAuthorization.Default"/> will be used.</param> public Board(string id, TrelloAuthorization auth = null) { Auth = auth; _context = new BoardContext(id, auth); _context.Synchronized += Synchronized; Id = id; _description = new Field <string>(_context, nameof(Description)); _isClosed = new Field <bool?>(_context, nameof(IsClosed)); _isClosed.AddRule(NullableHasValueRule <bool> .Instance); _isPinned = new Field <bool?>(_context, nameof(IsPinned)); _isPinned.AddRule(NullableHasValueRule <bool> .Instance); _isStarred = new Field <bool?>(_context, nameof(IsStarred)); _isStarred.AddRule(NullableHasValueRule <bool> .Instance); _isSubscribed = new Field <bool?>(_context, nameof(IsSubscribed)); _isSubscribed.AddRule(NullableHasValueRule <bool> .Instance); _name = new Field <string>(_context, nameof(Name)); _name.AddRule(NotNullOrWhiteSpaceRule.Instance); _organization = new Field <Organization>(_context, nameof(Organization)); Preferences = new BoardPreferences(_context.BoardPreferencesContext); PersonalPreferences = new BoardPersonalPreferences(() => Id, auth); _url = new Field <string>(_context, nameof(Url)); _shortUrl = new Field <string>(_context, nameof(ShortUrl)); _shortLink = new Field <string>(_context, nameof(ShortLink)); _lastActivity = new Field <DateTime?>(_context, nameof(LastActivity)); _lastViewed = new Field <DateTime?>(_context, nameof(LastViewed)); TrelloConfiguration.Cache.Add(this); }
public Attachment Get(int index) { using (var context = new BoardContext()) { return(context.Attachments.Single(a => a.Id == index)); } }
public Board Handle(BoardQuery request) { using (var _context = new BoardContext()) { return(_context.Boards.AsNoTracking().Include("Lists.Name").First(board => board.Id == request.Id)); } }
public List <Post> Get(string Username) { using (var context = new BoardContext()) { return(context.Posts.Include(p => p.User).Include(p => p.Channel).ToList()); } }
public List <User> GetBottom() { using (var context = new BoardContext()) { return(context.Users.OrderBy(u => u.Reputation).Take(10).ToList()); } }
public List <Post> Get() { using (var context = new BoardContext()) { context.Database.Log = Console.WriteLine; return(context.Posts.Include(p => p.User).Include(p => p.Channel).ToList()); } }
public void Add(Attachment attach) { using (var context = new BoardContext()) { context.Attachments.Add(attach); context.SaveChanges(); } }
public void Drop(int index) { using (var context = new BoardContext()) { context.Comments.Remove(context.Comments.Single(c => c.Id == index)); context.SaveChanges(); } }
public List <Comment> Get(Post post) { using (var context = new BoardContext()) { context.Database.Log = Console.WriteLine; return(context.Comments.Where(c => c.Post.Id == post.Id).Include(c => c.User).Include(c => c.Post).OrderByDescending(c => c.Date).ToList()); } }
public List <Comment> Get() { using (var context = new BoardContext()) { context.Database.Log = Console.WriteLine; return(context.Comments.ToList()); } }
public User Get(string uname) { using (var context = new BoardContext()) { context.Database.Log = Console.WriteLine; return(context.Users.First(a => a.Username == uname)); } }
public User Get(int index) { using (var context = new BoardContext()) { context.Database.Log = Console.WriteLine; return(context.Users.First(a => a.Id == index)); } }
public bool UsernameTaken(string Username) { using (var context = new BoardContext()) { var test = context.Users.Any(u => u.Username == Username); return(test); } }
public void Drop(int post) { using (var context = new BoardContext()) { context.Posts.Remove(context.Posts.Single(p => p.Id == post)); context.SaveChanges(); } }
public List <Reputation> Get() { using (var context = new BoardContext()) { context.Database.Log = Console.WriteLine; return(context.Reputations.ToList()); } }
public Post Get(int index) { using (var context = new BoardContext()) { context.Database.Log = Console.WriteLine; return(context.Posts.Include(p => p.User).Include(p => p.Channel).Single(a => a.Id == index)); } }
public bool EmailTaken(string EMail) { using (var context = new BoardContext()) { var test = context.Users.Any(u => u.EMail == EMail); return(test); } }
public List <Administrator> Get() { using (var context = new BoardContext()) { context.Database.Log = Console.WriteLine; return(context.Administrators.ToList()); } }
private void HandleInvalidInput(BoardContext board) { Console.Clear(); board.Print(printer); Console.WriteLine("Enter a valid position."); }
public Comment Get(int index) { using (var context = new BoardContext()) { context.Database.Log = Console.WriteLine; return(context.Comments.Single(a => a.Id == index)); } }