Exemplo n.º 1
0
        public static StoriesDetails GetStoryDetails(int storyId, int projectId)
        {
            using (ManagementSystemEntities db = new ManagementSystemEntities())
            {
                StoriesDetails model  = new StoriesDetails();
                var            result = (from story in db.Stories.Where(story => story.Id == storyId && story.ProjectId == projectId && story.IsDeleted == false)
                                         select new StoriesDetails
                {
                    Id = story.Id,
                    Name = story.Name,
                    ProjectId = story.ProjectId
                });
                model = result.FirstOrDefault();
                if (result != null)
                {
                    model.Sprints = (from s in db.Stories
                                     where (s.ProjectId == projectId && s.IsDeleted == false && s.Id == storyId)
                                     join sprint_story in db.SprintStories on s.Id equals sprint_story.StoryId
                                     join sprint in db.Sprints on sprint_story.SprintId equals sprint.Id
                                     select sprint).ToList();
                }

                return(model);
            }
        }
Exemplo n.º 2
0
        public ActionResult Create(StoryCreateModel storyModel, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Story model = new Story()
                    {
                        ProjectId = storyModel.ProjectId,
                        Exist     = false,
                        sprintId  = StoriesFilterSession.sprintId
                    };

                    if (storyModel.selectedType == 1)
                    {
                        model.Exist = true;
                        model.Name  = collection["search"].ToString();
                    }
                    else
                    {
                        model.Name = collection["NewStory"].ToString();
                    }
                    model.CreatorId  = SessionData.UserId;
                    model.CreateDate = DateTimeHelper.Today();

                    StoriesDetails newStory = StoriesLogic.InsertNewStory(model);
                    if (newStory != null)
                    {
                        StoriesFilter story = StoriesFilterSession;
                        story.AllStories.Add(newStory);
                        StoriesFilterSession = story;
                    }
                    if (newStory == null && storyModel.selectedType == 2)
                    {
                        // return pop up to set option for create with the same name
                    }
                }
                catch (Exception e)
                {
                    LogsLogic.InsertLog(new Log()
                    {
                        Message    = e.Message,
                        StackTrace = e.StackTrace,
                        StoryName  = "ManagementProject/Stories/Create(Post)",
                        Parameters = new JavaScriptSerializer().Serialize(storyModel)
                    });
                }
            }
            return(RedirectToAction("StoriesList", new { projectId = storyModel.ProjectId }));
        }
Exemplo n.º 3
0
 public void FinishCodeReview(int storyId, int projectId)
 {
     try
     {
         StoriesLogic.FinishCodeReview(storyId);
         StoriesDetails s = StoriesFilterSession.AllStories.FirstOrDefault(st => st.Id == storyId);
         // SetFilterStorySession();
     }
     catch (Exception e)
     {
         LogsLogic.InsertLog(new Log()
         {
             Message    = e.Message,
             StackTrace = e.StackTrace,
             StoryName  = "ManagementProject/Stories/FinishCodeReview",
             Parameters = " storyId=" + storyId + "& projectId = " + projectId
         });
     }
 }
Exemplo n.º 4
0
        public static StoriesDetails InsertNewStory(Story story)
        {
            StoriesDetails model = new StoriesDetails();

            if (story.Exist)
            {
                var q = CheckOfExistingStory(story);
                if (CheckIfStoryLinkedToSprint(story) == null)
                {
                    InsertSprintToStory(q.Id, story.sprintId);
                    model = GetStoryDetails(q.Id, story.ProjectId);
                }
            }
            else
            {
                if (CheckOfExistingStory(story) != null)
                {
                    return(model);
                }
                else
                {
                    using (ManagementSystemEntities db = new ManagementSystemEntities())
                    {
                        db.Stories.Add(story);
                        db.SaveChanges();
                        int         id           = db.Stories.OrderByDescending(x => x.Id).First().Id;
                        SprintStory sprint_story = new SprintStory()
                        {
                            SprintId = story.sprintId, StoryId = id
                        };
                        db.SprintStories.Add(sprint_story);
                        db.SaveChanges();
                        model = GetStoryDetails(id, story.ProjectId);
                    }
                }
            }
            return(model);
        }