Пример #1
0
        public int AddCard(Card card)
        {
            if (card == null)
            {
                throw new Exception("AddCard method error: Card is null");
            }


            var todolist = new Todolist
            {
                Title   = "Todolist",
                TodoIds = ""
            };

            _todolistContext.Todolists.Add(todolist);
            _todolistContext.SaveChanges();

            card.TodolistId = todolist.Id;
            _db.Cards.Add(card);
            _db.SaveChanges();

            var board = _dbBoard.Boards.Find(card.BoardId);

            board.AddCardId(card.Id);
            _dbBoard.Boards.Update(board);
            _dbBoard.SaveChanges();

            var column = _dbColumn.Columns.Find(card.ColumnId);

            column.AddCardId(card.Id);
            _dbColumn.Columns.Update(column);
            _dbColumn.SaveChanges();

            return(card.Id);
        }
 public int AddBoard(Board board)
 {
     if (board == null)
     {
         throw new Exception("AddBoard method error: board is null");
     }
     _db.Boards.Add(board);
     _db.SaveChanges();
     return(board.Id);
 }
Пример #3
0
        public void UpdateCard(CardDetails cardModel)
        {
            var card = boardContext.Cards.FirstOrDefault(x => x.Id == cardModel.Id);

            card.Notes    = cardModel.Notes;
            card.Title    = cardModel.Title;
            card.ColumnId = cardModel.ColumnId;

            boardContext.SaveChanges();
        }
Пример #4
0
        public ActionResult AddCardSignal(Card card)
        {
            if (ModelState.IsValid)
            {
                db.Cards.Add(card);
                db.SaveChanges();

                return(Json(card.CardID, JsonRequestBehavior.AllowGet));
            }
            return(Json(null, JsonRequestBehavior.AllowGet));
        }
Пример #5
0
        public ActionResult Create(Board board)
        {
            if (ModelState.IsValid)
            {
                db.Boards.Add(board);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(board));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "JobID,Title,PositionType,Salary")] Job job)
        {
            if (ModelState.IsValid)
            {
                db.Jobs.Add(job);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(job));
        }
        public IActionResult Post(int boardId, string name)
        {
            var state = new IssueState
            {
                Name    = name,
                BoardId = boardId
            };

            _context.IssueStates.Add(state);
            _context.SaveChanges();

            _connectionManager.BroadcastAddState(Result.ToModel(state));

            return(Result.Created(state));
        }
Пример #8
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!"));
        }
Пример #9
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();
     }
 }
Пример #10
0
 public void Drop(int post)
 {
     using (var context = new BoardContext())
     {
         context.Posts.Remove(context.Posts.Single(p => p.Id == post));
         context.SaveChanges();
     }
 }
Пример #11
0
 public void Drop(int index)
 {
     using (var context = new BoardContext())
     {
         context.Comments.Remove(context.Comments.Single(c => c.Id == index));
         context.SaveChanges();
     }
 }
Пример #12
0
 public void Add(Attachment attach)
 {
     using (var context = new BoardContext())
     {
         context.Attachments.Add(attach);
         context.SaveChanges();
     }
 }
Пример #13
0
 public void Add(Channel channel)
 {
     using (var context = new BoardContext())
     {
         context.Channels.Add(channel);
         context.SaveChanges();
     }
 }
Пример #14
0
 public void Edit(User user)
 {
     using (var context = new BoardContext())
     {
         context.Database.Log      = Console.WriteLine;
         context.Entry(user).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Пример #15
0
 public void Add(User user)
 {
     using (var context = new BoardContext())
     {
         context.Database.Log = Console.WriteLine;
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
        public IActionResult Post(int boardId, int?stateId, string title)
        {
            var issue = new Issue
            {
                Title   = title,
                BoardId = boardId,
                StateId = stateId
            };

            _context.Issues.Add(issue);
            _context.SaveChanges();

            var issueModel = Result.ToModel(issue);

            _connectionManager.BroadcastAddIssue(issueModel);

            return(Result.Created(issue));
        }
Пример #17
0
 public void Add(Announcement announcement)
 {
     using (var context = new BoardContext())
     {
         announcement.Administrator = context.Administrators.Single(o => o.Id == announcement.Id);
         context.Announcments.Add(announcement);
         context.SaveChanges();
     }
 }
Пример #18
0
 public void Add(Administrator admin)
 {
     using (var context = new BoardContext())
     {
         context.Database.Log = Console.WriteLine;
         context.Administrators.Add(admin);
         context.SaveChanges();
     }
 }
Пример #19
0
 public ActionResult Create([Bind(Include = "LastName, FirstName, Degree")] Candidate candidate)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Candidates.Add(candidate);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (RetryLimitExceededException /* dex */)
     {
         //Log the error (uncomment dex variable name and add a line here to write a log.
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return(View(candidate));
 }
Пример #20
0
 public ActionResult Create(Board model)
 {
     if (ModelState.IsValid)
     {
         _context.Boards.Add(model);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Пример #21
0
        public int AddColumn(Column column)
        {
            if (column == null)
            {
                throw new Exception("AddColumn method error: column is null");
            }
            var board = _dbBoards.Boards.Find(column.BoardId);

            if (board == null)
            {
                throw new Exception("AddColumn method error: board is null");
            }
            _db.Columns.Add(column);
            _db.SaveChanges();
            board.AddColumnId(column.Id);
            _dbBoards.Update(board);
            _dbBoards.SaveChanges();
            return(column.Id);
        }
Пример #22
0
        public void Edit(Comment comment)
        {
            using (var context = new BoardContext())
            {
                var dbComment = context.Comments.Include(u => u.User).Include(p => p.Post).Single(c => c.Id == comment.Id);
                dbComment.Content = comment.Content;

                context.Entry(dbComment).State = EntityState.Modified;
                context.SaveChanges();
            }
        }
Пример #23
0
 public void Edit(Post post)
 {
     using (var context = new BoardContext())
     {
         Post dbPost = context.Posts.Include(p => p.User).Include(p => p.Channel).Single(p => p.Id == post.Id);
         dbPost.Content = post.Content;
         dbPost.Title   = post.Title;
         context.Entry(dbPost).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Пример #24
0
 public void Drop(int channel)
 {
     using (var context = new BoardContext())
     {
         var dChannel = context.Channels.Single(c => c.Id == channel);
         if (dChannel != null)
         {
             context.Channels.Remove(dChannel);
         }
         context.SaveChanges();
     }
 }
Пример #25
0
 public void Add(Post post)
 {
     using (var context = new BoardContext())
     {
         context.Database.Log = Console.WriteLine;
         var id = post.User.Id;
         post.User    = context.Users.Single(o => o.Id == id);
         post.Channel = context.Channels.Single(c => c.Id == post.Channel.Id);
         context.Posts.Add(post);
         context.SaveChanges();
     }
 }
Пример #26
0
        public IActionResult Post(string name)
        {
            var board = new Board
            {
                Name = name
            };

            _context.Boards.Add(board);
            _context.SaveChanges();

            return(Result.Created(board));
        }
Пример #27
0
        public void Drop(Announcement announcement)
        {
            using (var context = new BoardContext())
            {
                var dAnn = context.Announcments.Single(a => a.Id == announcement.Id);
                if (dAnn != null)
                {
                    context.Announcments.Remove(dAnn);
                }

                context.SaveChanges();
            }
        }
Пример #28
0
        public void Drop(Attachment attach)
        {
            using (var context = new BoardContext())
            {
                var dAttach = context.Attachments.Single(a => a.Id == attach.Id);
                if (dAttach != null)
                {
                    context.Attachments.Remove(dAttach);
                }

                context.SaveChanges();
            }
        }
Пример #29
0
        public void Add(Comment comment)
        {
            using (var context = new BoardContext())
            {
                context.Database.Log = Console.WriteLine;

                comment.Post = context.Posts.Single(p => p.Id == comment.Post.Id);
                comment.User = context.Users.Single(u => u.Id == comment.User.Id);
                comment.Date = DateTime.Now;

                context.Comments.Add(comment);
                context.SaveChanges();
            }
        }
Пример #30
0
 // POST api/boardapi
 public List Post([FromBody] CreateList input)
 {
     using (var ctx = new BoardContext())
     {
         Board board = ctx.Boards.Where(b => b.Id == input.BoardId).First();
         var   list  = new List {
             Name = input.name
         };
         board.Lists.Add(list);
         ctx.Set <List>().Add(list);
         ctx.SaveChanges();
         return(list);
     }
 }