Ejemplo n.º 1
0
 public override string CreateSort(string projectId, Project clonedProject)
 {
     using (var dbContext = new ProjectContext())
     {
         var sortSession = new SortSession()
         {
             Project   = clonedProject,
             ProjectId = clonedProject.Id,
             Reference = projectId
         };
         dbContext.SortSessions.Add(sortSession);
         dbContext.SaveChanges();
         return(sortSession.Id);
     }
 }
Ejemplo n.º 2
0
        public override bool SaveSort(SortSession session)
        {
            using (var dbContext = new ProjectContext())
            {
                // For some reason, the default group still seems to contain all the cards.
                // Make sure to remove all the cards from the default or unsorted group.
                session.Project.Groups.First(x => x.IsUnsorted == true).Cards.Clear();

                // Save the cloned project.
                var existingProject = dbContext.Projects.FirstOrDefault(x => x.Id == session.Project.Id);
                if (existingProject == null)
                {
                    dbContext.Add(session.Project);
                    dbContext.SaveChanges();
                }
                else
                {
                    dbContext.Remove(existingProject);
                    dbContext.SaveChanges();
                    dbContext.Add(session.Project);
                    dbContext.SaveChanges();
                }

                // Save the sort session.
                var existingSession = dbContext.SortSessions.FirstOrDefault(x => x.Id == session.Id);
                if (existingSession == null)
                {
                    dbContext.Add(session);
                    dbContext.SaveChanges();
                }
                else
                {
                    dbContext.Remove(existingSession);
                    dbContext.SaveChanges();
                    dbContext.Add(session);
                    dbContext.SaveChanges();
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
 public bool Upload([FromBody] SortSession sortSession)
 {
     return(projectManager.SaveSort(sortSession));
 }