예제 #1
0
        public void create(string userId, Team team)
        {
            EntityFrameworkContext db;

            using (db = new EntityFrameworkContext())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        team.TeamLeaderUserId = userId;
                        db.TeamList.Add(team);
                        db.SaveChanges();

                        var user = db.Users.Find(userId);
                        user.TeamId = team.Id;

                        db.SaveChanges();

                        dbContextTransaction.Commit();
                    }
                    catch (Exception)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }
        }
예제 #2
0
        public void Add(Task task)
        {
            var db = new EntityFrameworkContext();

            task.CreatedAt = DateTime.Now;
            task.UpdatedAt = DateTime.Now;
            db.TaskList.Add(task);
            db.SaveChanges();
        }
예제 #3
0
        public void edit(Team updatedTeam)
        {
            var db       = new EntityFrameworkContext();
            var original = db.TeamList.Find(updatedTeam.Id);

            if (original != null)
            {
                db.Entry(original).CurrentValues.SetValues(updatedTeam);
                db.SaveChanges();
            }
        }
        public void Delete(int id)
        {
            var     db      = new EntityFrameworkContext();
            Comment comment = new Comment {
                Id = id
            };

            db.CommentList.Attach(comment);
            db.CommentList.Remove(comment);
            db.SaveChanges();
        }
예제 #5
0
        public void Edit(int id, Task updatedTask)
        {
            var db       = new EntityFrameworkContext();
            var original = db.TaskList.Find(id);

            if (original != null)
            {
                updatedTask.CreatedAt = original.CreatedAt;
                updatedTask.UpdatedAt = DateTime.Now;
                db.Entry(original).CurrentValues.SetValues(updatedTask);
                db.SaveChanges();
            }
        }
        public void Edit(int id, Comment updatedComment)
        {
            var db       = new EntityFrameworkContext();
            var original = db.CommentList.Find(id);

            if (original != null)
            {
                updatedComment.PostedAt  = original.PostedAt;
                updatedComment.UpdatedAt = DateTime.Now;
                db.Entry(original).CurrentValues.SetValues(updatedComment);
                db.SaveChanges();
            }
        }
예제 #7
0
        public void Delete(int id)
        {
            var  db   = new EntityFrameworkContext();
            Task task = new Task {
                Id = id
            };

            db.TaskList.Attach(task);
            db.TaskList.Remove(task);
            db.SaveChanges();
            CommentRepository commentRepository = CommentRepository.getInstance();

            commentRepository.DeleteComments(id);
        }
        public void Add(Comment comment, int taskId)
        {
            TaskRepository taskRepository = TaskRepository.getInstance();
            var            task           = taskRepository.Search(taskId);

            if (task == null)
            {
                return;
            }

            comment.PostedAt  = DateTime.Now;
            comment.UpdatedAt = DateTime.Now;
            comment.TaskId    = taskId;

            var db = new EntityFrameworkContext();

            db.CommentList.Add(comment);
            db.SaveChanges();
        }