Esempio n. 1
0
        public bool Add(string createdByUserId, StoryCreateModel newstory, List <int> groupIds)
        {
            var story = new Story();

            story.PostedOn    = DateTime.Now;
            story.UserId      = createdByUserId;
            story.Title       = newstory.Title;
            story.Content     = newstory.Content;
            story.Description = newstory.Description;
            //foreach (var group in _groupRepository.Get.Where(g => groupIds.Contains(g.Id)).ToList())
            //{
            //    story.Groups.Add(group);
            //}
            story.Groups = _groupRepository.Get.Where(g => groupIds.Contains(g.Id)).ToList();

            try
            {
                _storyRepository.Add(story);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public bool Add(string createdByUserId, StoryCreateModel newstory, List<int> groupIds)
        {
            var story = new Story();
            story.PostedOn = DateTime.Now;
            story.UserId = createdByUserId;
            story.Title = newstory.Title;
            story.Content = newstory.Content;
            story.Description = newstory.Description;
            //foreach (var group in _groupRepository.Get.Where(g => groupIds.Contains(g.Id)).ToList())
            //{
            //    story.Groups.Add(group);
            //}
             story.Groups=_groupRepository.Get.Where(g=>groupIds.Contains(g.Id)).ToList();

            try
            {
                _storyRepository.Add(story);

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Esempio n. 3
0
        public ActionResult Create(int projectId)
        {
            StoryCreateModel story = new StoryCreateModel {
                ProjectId = projectId, selectedType = 1
            };

            return(View(story));
        }
Esempio n. 4
0
 public ActionResult Create(StoryCreateModel model, List <int> groups)
 {
     model.Groups = groups.Select(id => new GroupSelectModel()
     {
         Id = id
     }).ToList();
     _storyService.Add(User.Identity.GetUserId(), model, groups);
     return(RedirectToAction("Index"));
 }
Esempio n. 5
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 }));
        }
 public ActionResult Create(StoryCreateModel model, List<int> groups)
 {
     model.Groups = groups.Select(id => new GroupSelectModel() { Id=id}).ToList();
         _storyService.Add(User.Identity.GetUserId(), model,groups);
         return RedirectToAction("Index");
 }