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);
        }
Exemplo n.º 2
0
 public Announcement Get(int id)
 {
     using (var context = new BoardContext())
     {
         return(context.Announcments.Single(a => a.Id == id));
     }
 }
Exemplo n.º 3
0
 public int GetRep(User user)
 {
     using (var context = new BoardContext())
     {
         return(context.Reputations.Count(a => a.Receiver.Id == user.Id));
     }
 }
Exemplo n.º 4
0
 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();
     }
 }
Exemplo n.º 5
0
 public RepairCaseRepository(BoardContext context, WorkerRepository workerRepository,
                             EquipmentRepository equipmentRepository)
 {
     _context             = context;
     _workerRepository    = workerRepository;
     _equipmentRepository = equipmentRepository;
 }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
        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!"));
        }
Exemplo n.º 8
0
 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());
     }
 }
Exemplo n.º 9
0
 public List <Announcement> Get()
 {
     using (var context = new BoardContext())
     {
         return(context.Announcments.ToList());
     }
 }
Exemplo n.º 10
0
 public List <Attachment> Get(Post post)
 {
     using (var context = new BoardContext())
     {
         return(context.Attachments.Where(a => a.Post.Id == post.Id).ToList());
     }
 }
Exemplo n.º 11
0
        /// <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);
        }
Exemplo n.º 12
0
 public Attachment Get(int index)
 {
     using (var context = new BoardContext())
     {
         return(context.Attachments.Single(a => a.Id == index));
     }
 }
Exemplo n.º 13
0
 public Board Handle(BoardQuery request)
 {
     using (var _context = new BoardContext())
     {
         return(_context.Boards.AsNoTracking().Include("Lists.Name").First(board => board.Id == request.Id));
     }
 }
Exemplo n.º 14
0
 public List <Post> Get(string Username)
 {
     using (var context = new BoardContext())
     {
         return(context.Posts.Include(p => p.User).Include(p => p.Channel).ToList());
     }
 }
Exemplo n.º 15
0
 public List <User> GetBottom()
 {
     using (var context = new BoardContext())
     {
         return(context.Users.OrderBy(u => u.Reputation).Take(10).ToList());
     }
 }
Exemplo n.º 16
0
 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());
     }
 }
Exemplo n.º 17
0
 public void Add(Attachment attach)
 {
     using (var context = new BoardContext())
     {
         context.Attachments.Add(attach);
         context.SaveChanges();
     }
 }
Exemplo n.º 18
0
 public void Drop(int index)
 {
     using (var context = new BoardContext())
     {
         context.Comments.Remove(context.Comments.Single(c => c.Id == index));
         context.SaveChanges();
     }
 }
Exemplo n.º 19
0
 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());
     }
 }
Exemplo n.º 20
0
 public List <Comment> Get()
 {
     using (var context = new BoardContext())
     {
         context.Database.Log = Console.WriteLine;
         return(context.Comments.ToList());
     }
 }
Exemplo n.º 21
0
 public User Get(string uname)
 {
     using (var context = new BoardContext())
     {
         context.Database.Log = Console.WriteLine;
         return(context.Users.First(a => a.Username == uname));
     }
 }
Exemplo n.º 22
0
 public User Get(int index)
 {
     using (var context = new BoardContext())
     {
         context.Database.Log = Console.WriteLine;
         return(context.Users.First(a => a.Id == index));
     }
 }
Exemplo n.º 23
0
 public bool UsernameTaken(string Username)
 {
     using (var context = new BoardContext())
     {
         var test = context.Users.Any(u => u.Username == Username);
         return(test);
     }
 }
Exemplo n.º 24
0
 public void Drop(int post)
 {
     using (var context = new BoardContext())
     {
         context.Posts.Remove(context.Posts.Single(p => p.Id == post));
         context.SaveChanges();
     }
 }
Exemplo n.º 25
0
 public List <Reputation> Get()
 {
     using (var context = new BoardContext())
     {
         context.Database.Log = Console.WriteLine;
         return(context.Reputations.ToList());
     }
 }
Exemplo n.º 26
0
 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));
     }
 }
Exemplo n.º 27
0
 public bool EmailTaken(string EMail)
 {
     using (var context = new BoardContext())
     {
         var test = context.Users.Any(u => u.EMail == EMail);
         return(test);
     }
 }
Exemplo n.º 28
0
 public List <Administrator> Get()
 {
     using (var context = new BoardContext())
     {
         context.Database.Log = Console.WriteLine;
         return(context.Administrators.ToList());
     }
 }
Exemplo n.º 29
0
        private void HandleInvalidInput(BoardContext board)
        {
            Console.Clear();

            board.Print(printer);

            Console.WriteLine("Enter a valid position.");
        }
Exemplo n.º 30
0
 public Comment Get(int index)
 {
     using (var context = new BoardContext())
     {
         context.Database.Log = Console.WriteLine;
         return(context.Comments.Single(a => a.Id == index));
     }
 }