public JsonSprintBurnDown(int sprintId)
            : base()
        {
            Data = new List<object>();
            YAxisMin = 0;

            if (sprintId >= 0)
            {
                ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
                SprintService sprintService = new SprintService(scrumTimeEntities);
                Sprint sprint = sprintService.GetSprintById(sprintId);
                if (sprint != null && sprint.Scrums.Count() > 0)
                {
                    Data.Add(CreateIdealScrumTaskJsonList(sprint));
                    Data.Add(CreateScrumTaskJsonList(sprint));

                    XAxisMinDate = sprint.StartDate.ToString("MM/dd/yyyy");
                    XAxisMaxDate = sprint.FinishDate.ToString("MM/dd/yyyy");
                    YAxisMin = 0;

                    ScrumService scrumService = new ScrumService(scrumTimeEntities);
                    YAxisMax = scrumService.GetMaxTaskHourCountBySprintId(sprint.SprintId);
                }
                else
                    HandleBadSprint();
            }
            else
                HandleBadSprint();
        }
 public virtual ActionResult Index()
 {
     ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
     string currentProductName = "None";
     string currentSprintName = "None";
     string nextReleaseName = "None";
     ProductService productService = new ProductService(scrumTimeEntities);
     Product product = productService.GetProductById(SessionHelper.GetCurrentProductId(User.Identity.Name, Session));
     if (product != null && product.ProductId > 0)
     {
         currentProductName = product.Name;
         SprintService sprintService = new SprintService(scrumTimeEntities);
         Sprint sprint = sprintService.GetSprintById(SessionHelper.GetCurrentSprintId(User.Identity.Name, Session));
         if (sprint != null && sprint.SprintId > 0)
         {
             currentSprintName = sprint.Name;
             ReleaseService releaseService = new ReleaseService(scrumTimeEntities);
             Release nextRelease = releaseService.GetNextReleaseEqOrAfterDate(sprint.ProductId, sprint.FinishDate);
             if (nextRelease != null && nextRelease.ReleaseId > 0)
                 nextReleaseName = nextRelease.Name;
         }
     }
     DashboardViewModel dashboardViewModel = new DashboardViewModel()
     {
         CurrentProductName = currentProductName,
         CurrentSprintName = currentSprintName,
         NextReleaseName = nextReleaseName
     };
     return PartialView(dashboardViewModel);
 }
Example #3
0
        public Product SaveProduct(Product product)
        {
            if (product != null)
            {
                if (product.ProductId == 0)  // this is new
                {
                    _ScrumTimeEntities.AddToProducts(product);
                }
                else  // the product exists
                {
                    _ScrumTimeEntities.AttachTo("Products", product);

                    ScrumTimeEntities freshScrumTimeEntities =
                        new ScrumTimeEntities(_ScrumTimeEntities.Connection.ConnectionString);
                    Product existingProduct = GetProductById(freshScrumTimeEntities, product.ProductId);
                    if (existingProduct == null)
                    {
                        throw new Exception("The product no longer exists.");
                    }
                    _ScrumTimeEntities.ObjectStateManager.ChangeObjectState(product, System.Data.EntityState.Modified);
                }
                _ScrumTimeEntities.SaveChanges();
            }
            return product;
        }
Example #4
0
        public static void CreateFirstTimeDefaults(string username)
        {
            ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
            UserSetting userSetting = UserSettingService.GetUserSettingByUsername(scrumTimeEntities, username);
            if (userSetting == null)
            {
                // Load sample product id
                ProductService productService = new ProductService(scrumTimeEntities);
                int productIdOfSample = productService.GetProductIdOfSample();
                if (productIdOfSample > -1)
                {
                    SprintService sprintService = new SprintService(scrumTimeEntities);
                    List<Sprint> mostRecentSprints = sprintService.GetMostRecentSprints(productIdOfSample, -1, 1);
                    if (mostRecentSprints.Count > 0 && mostRecentSprints[0] != null)
                    {
                        userSetting = new UserSetting()
                        {
                            CurrentProduct = productIdOfSample,
                            CurrentSprint = mostRecentSprints[0].SprintId,
                            LastMainTabSelected = 1,
                            Username = username
                        };
                        scrumTimeEntities.AddToUserSettings(userSetting);
                        scrumTimeEntities.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
                    }

                }
            }
        }
Example #5
0
        public Story SaveStory(Story story)
        {
            if (story != null)
            {
                if (story.StoryId == 0)  // this is new
                {
                    SetPriorityForSave(story, 0, story.Priority);
                    _ScrumTimeEntities.AddToStories(story);
                }
                else  // the story exists
                {
                    _ScrumTimeEntities.AttachTo("Stories", story);

                    ScrumTimeEntities freshScrumTimeEntities =
                        new ScrumTimeEntities(_ScrumTimeEntities.Connection.ConnectionString);
                    Story existingStory = GetStoryById(freshScrumTimeEntities, story.StoryId);
                    if (existingStory != null && existingStory.StoryId > 0)
                    {
                        SetPriorityForSave(story, existingStory.Priority, story.Priority);
                    }
                    else
                    {
                        throw new Exception("The story no longer exists.");
                    }
                    _ScrumTimeEntities.ObjectStateManager.ChangeObjectState(story, System.Data.EntityState.Modified);
                }
                _ScrumTimeEntities.SaveChanges();
            }
            return story;
        }
        public UserSetting SaveUserSetting(UserSetting userSetting)
        {
            if (userSetting != null)
            {
                if (userSetting.UserSettingId == 0)  // this is new
                {
                    _ScrumTimeEntities.AddToUserSettings(userSetting);
                }
                else  // the userSetting exists
                {
                    _ScrumTimeEntities.AttachTo("UserSettings", userSetting);

                    ScrumTimeEntities freshScrumTimeEntities =
                        new ScrumTimeEntities(_ScrumTimeEntities.Connection.ConnectionString);
                    UserSetting existingUserSetting = GetUserSettingByUsername(freshScrumTimeEntities, userSetting.Username);
                    if (existingUserSetting == null)
                    {
                        throw new Exception("The user setting no longer exists.");
                    }
                    _ScrumTimeEntities.ObjectStateManager.ChangeObjectState(userSetting, System.Data.EntityState.Modified);
                }
                _ScrumTimeEntities.SaveChanges();
            }
            return userSetting;
        }
Example #7
0
 public static List<Task> GetTasksByStoryIdOrderbyIdAsc(ScrumTimeEntities scrumTimeEntities, int storyId)
 {
     var results = from t in scrumTimeEntities.Tasks
                   where t.StoryId == storyId
                   orderby t.TaskId ascending
                   select t;
     return results.ToList<Task>();
 }
Example #8
0
 public void ChangePriorityOfExistingStory()
 {
     ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
     StoryService storyService = new StoryService(scrumTimeEntities);
     Story story = storyService.GetStoryById(2);
     story.Priority = 0;
     storyService.SaveStory(story);
 }
Example #9
0
 public static List<Sprint> GetAllSprints(ScrumTimeEntities scrumTimeEntities,
         int productId)
 {
     var results = from t in scrumTimeEntities.Sprints
                   where t.ProductId == productId
                   orderby t.FinishDate descending
                   select t;
     return results.ToList<Sprint>();
 }
Example #10
0
 public void GetSprintsWithinDateRangeTest()
 {
     ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
     SprintService sprintService = new SprintService(scrumTimeEntities);
     List<Sprint> sprints =
         sprintService.GetSprintsWithinDateRange(1, new DateTime(2010, 1, 1),
             new DateTime(2010, 6, 5));
     Assert.AreEqual(5, sprints.Count());
 }
Example #11
0
 public static Scrum GetScrumById(ScrumTimeEntities scrumTimeEntities, int id)
 {
     Scrum scrum = null;
     var results = from s in scrumTimeEntities.Scrums
                   where s.ScrumId == id
                   select s;
     if (results.Count() > 0)
         scrum = results.First<Scrum>();
     return scrum;
 }
 public static UserSetting GetUserSettingByUsername(ScrumTimeEntities scrumTimeEntities, string username)
 {
     UserSetting userSetting = null;
     var results = from u in scrumTimeEntities.UserSettings
                   where u.Username == username
                   select u;
     if (results.Count() > 0)
         userSetting = results.First<UserSetting>();
     return userSetting;
 }
Example #13
0
 public static Scrum GetScrumByDateOfScrumAndSprintId(ScrumTimeEntities scrumTimeEntities, 
     DateTime dateOfScrum, int sprintId)
 {
     Scrum scrum = null;
     var results = from s in scrumTimeEntities.Scrums
                   where s.DateOfScrum == dateOfScrum &&
                   s.SprintId == sprintId
                   select s;
     if (results.Count() > 0)
         scrum = results.First<Scrum>();
     return scrum;
 }
Example #14
0
 public static Story GetStoryById(ScrumTimeEntities scrumTimeEntities, int id)
 {
     Story story = null;
     var results = from s in scrumTimeEntities.Stories
                   where s.StoryId == id
                   select s;
     if (results.Count() > 0)
         story = results.First<Story>();
     else
         story = new Story();
     return story;
 }
Example #15
0
 public static Task GetTaskById(ScrumTimeEntities scrumTimeEntities, int id)
 {
     Task task = null;
     var results = from t in scrumTimeEntities.Tasks
                   where t.TaskId == id
                   select t;
     if (results.Count() > 0)
         task = results.First<Task>();
     else
         task = new Task();
     return task;
 }
Example #16
0
 public static Release GetReleaseById(ScrumTimeEntities scrumTimeEntities, int id)
 {
     Release release = null;
     var results = from t in scrumTimeEntities.Releases
                   where t.ReleaseId == id
                   select t;
     if (results.Count() > 0)
         release = results.First<Release>();
     else
         release = new Release();
     return release;
 }
Example #17
0
 public static Product GetProductById(ScrumTimeEntities scrumTimeEntities, int id)
 {
     Product product = null;
     var results = from t in scrumTimeEntities.Products
                   where t.ProductId == id
                   select t;
     if (results.Count() > 0)
         product = results.First<Product>();
     else
         product = new Product();
     return product;
 }
Example #18
0
 public static Sprint GetSprintById(ScrumTimeEntities scrumTimeEntities, int id)
 {
     Sprint sprint = null;
     var results = from t in scrumTimeEntities.Sprints
                   where t.SprintId == id
                   select t;
     if (results.Count() > 0)
         sprint = results.First<Sprint>();
     else
         sprint = new Sprint();
     return sprint;
 }
        public static StoryCollectionViewModel BuildByPriorityAsc(int productId)
        {
            ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
            StoryCollectionViewModel storyCollectionViewModel = new StoryCollectionViewModel();
            Product product = scrumTimeEntities.Products.First<Product>(p => p.ProductId == productId);
            var results = from s in product.Stories
                          orderby s.Priority ascending
                          select s;
            List<Story> stories = results.ToList<Story>();
            storyCollectionViewModel.Stories = stories;

            return storyCollectionViewModel;
        }
Example #20
0
 public void AddNewStory()
 {
     ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
     StoryService storyService = new StoryService(scrumTimeEntities);
     Story story = new Story()
     {
         Narrative = "Test story",
         Points = 8,
         Priority = 2,
         ProductId = 1,
         UserDefinedId = "not set"
     };
     storyService.SaveStory(story);
 }
        public static SprintCollectionViewModel BuildByStartDateDesc(int productId)
        {
            ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
            SprintCollectionViewModel sprintCollectionViewModel = new SprintCollectionViewModel();
            Product product = scrumTimeEntities.Products.First<Product>(p => p.ProductId == productId);
            var results = from s in product.Sprints
                          orderby s.StartDate descending
                          select s;
            List<Sprint> sprints = results.ToList<Sprint>();
            sprintCollectionViewModel.Sprints = sprints;
            sprintCollectionViewModel.ProductId = productId;

            return sprintCollectionViewModel;
        }
        public static ReleaseCollectionViewModel BuildByTargetDateDesc(int productId)
        {
            ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
            ReleaseCollectionViewModel releaseCollectionViewModel = new ReleaseCollectionViewModel();
            Product product = scrumTimeEntities.Products.First<Product>(p => p.ProductId == productId);
            var results = from s in product.Releases
                          orderby s.Target descending
                          select s;
            List<Release> releases = results.ToList<Release>();
            releaseCollectionViewModel.Releases = releases;
            releaseCollectionViewModel.ProductId = productId;

            return releaseCollectionViewModel;
        }
Example #23
0
        public void DeleteStory()
        {
            ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
            StoryService storyService = new StoryService(scrumTimeEntities);
            Story story = new Story()
            {
                Narrative = "Test story for deletion test.",
                Points = 8,
                Priority = 2,
                ProductId = 1,
                UserDefinedId = "not set"
            };
            storyService.SaveStory(story);

            storyService.DeleteStory(story.StoryId);
        }
        public static TaskCollectionViewModel BuildByIdAsc(int storyId)
        {
            ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
            StoryService storyService = new StoryService(scrumTimeEntities);
            Story parentStory = storyService.GetStoryById(storyId);

            var results = from t in parentStory.Tasks
                          orderby t.TaskId ascending
                          select t;
            TaskCollectionViewModel taskCollectionViewModel = new TaskCollectionViewModel()
            {
                ParentStoryModel = parentStory,
                SortedTaskModels = results.ToList<Task>()
            };

            return taskCollectionViewModel;
        }
Example #25
0
        public void DeleteScrum(ScrumTimeEntities scrumTimeEntities, int scrumId)
        {
            Scrum existingScrum = GetScrumById(scrumTimeEntities, scrumId);

            if (existingScrum != null && existingScrum.ScrumId > 0)
            {
                List<ScrumDetail> scrumDetails = existingScrum.ScrumDetails.ToList<ScrumDetail>();
                foreach (ScrumDetail scrumDetail in scrumDetails)
                {
                    scrumTimeEntities.DeleteObject(scrumDetail);
                }
                scrumTimeEntities.DeleteObject(existingScrum);
                scrumTimeEntities.SaveChanges();
            }
            else
                throw new Exception("You have attempted to delete a scrum that does not exist.");
        }
        public JsonTaskHoursPerSprint(int productId, int currentSprintId)
            : base()
        {
            Data = new List<object>();
            Ticks = new List<string>();
            YAxisMin = 0;

            if (productId >= 0)
            {
                ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
                ProductService productService = new ProductService(scrumTimeEntities);
                Product product = productService.GetProductById(productId);

                Data.Add(CreateTaskHoursPerSprintJsonList(product, currentSprintId));
            }
            else
                HandleBadProductId();
        }
Example #27
0
 public static int GetCurrentSprintId(string username, HttpSessionStateBase session)
 {
     var value = session[CURRENTSPRINTID];
     if (value == null)
     {
         // check the db
         ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
         UserSetting userSetting = LoadUserSetting(scrumTimeEntities, username);
         if (userSetting != null && userSetting.CurrentSprint != null)
         {
             session[CURRENTSPRINTID] = userSetting.CurrentSprint;
             value = userSetting.CurrentSprint;
         }
         else
             value = -1;
     }
     return (int)value;
 }
        // [['08/03/2010', 51, '08/03/2010'], ['08/05/2010', 0, '08/05/2010']]
        private List<object> CreateIdealScrumTaskJsonList(Sprint sprint)
        {
            ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
            SprintService sprintService = new SprintService(scrumTimeEntities);

            List<object> idealScrumTaskJsonList = new List<object>();
            List<object> scrumDetailList1 = new List<object>();
            List<object> scrumDetailList2 = new List<object>();
            if (sprint != null)
            {
                scrumDetailList1.Add(sprint.StartDate.ToString("MM/dd/yyyy"));
                scrumDetailList1.Add(sprintService.GetTotalHourCount(sprint.SprintId));
                scrumDetailList1.Add(sprint.StartDate.ToString("MM/dd/yyyy"));
                idealScrumTaskJsonList.Add(scrumDetailList1);

                scrumDetailList2.Add(sprint.FinishDate.ToString("MM/dd/yyyy"));
                scrumDetailList2.Add(0);
                scrumDetailList2.Add(sprint.FinishDate.ToString("MM/dd/yyyy"));
                idealScrumTaskJsonList.Add(scrumDetailList2);
            }
            return idealScrumTaskJsonList;
        }
        public static ScrumCollectionViewModel BuildByDateOfScrumDesc(int productId, int selectedSprintId)
        {
            ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
            ScrumCollectionViewModel scrumCollectionViewModel = new ScrumCollectionViewModel(selectedSprintId);
            if (selectedSprintId > 0)
            {
                Sprint sprint = scrumTimeEntities.Sprints.First<Sprint>(s => s.SprintId == selectedSprintId);
                var results = from s in sprint.Scrums
                              orderby s.DateOfScrum ascending
                              select s;
                List<Scrum> scrums = results.ToList<Scrum>();
                scrumCollectionViewModel.Scrums = scrums;
            }
            scrumCollectionViewModel.Usernames = new List<string>();
            AccountMembershipService membershipService = new AccountMembershipService();
            MembershipUserCollection membershipUserCollection = membershipService.GetAllUsers();
            foreach (MembershipUser user in membershipUserCollection)
            {
                scrumCollectionViewModel.Usernames.Add(user.UserName);
            }

            return scrumCollectionViewModel;
        }
        public static ProductCollectionViewModel BuildByNameAlphabetical(int currentProductId)
        {
            ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
            ProductCollectionViewModel productCollectionViewModel = new ProductCollectionViewModel()
            {
                ProductViewModels = new List<ProductViewModel>()
            };

            var results = from p in scrumTimeEntities.Products
                          orderby p.Name ascending
                          select p;
            foreach (Product product in results)
            {
                ProductViewModel productViewModel = new ProductViewModel()
                {
                    IsCurrent = (product.ProductId == currentProductId) ? true : false,
                    ProductModel = product
                };
                productCollectionViewModel.ProductViewModels.Add(productViewModel);
            }

            return productCollectionViewModel;
        }