Пример #1
0
        public static TModel FromEpic <TModel>(Epic epic) where
        TModel : EpicApiModel, new()
        {
            var model = new TModel();

            model.Id          = epic.Id;
            model.Name        = epic.Name;
            model.ProductId   = epic.ProductId;
            model.Description = epic.Description;
            model.Stories     = epic.Stories.Where(s => !s.IsDeleted)
                                .OrderBy(x => x.Name)
                                .OrderByDescending(x => x.Priority)
                                .Select(x => StoryApiModel.FromStory(x)).ToList();
            model.Priority = epic.Priority;
            model.Product  = ProductApiModel.FromProduct(epic.Product);

            return(model);
        }
Пример #2
0
        public object ChangeStory(int roomId, int storyId, [FromBody] StoryApiModel storyModel)
        {
            var room = this.Rooms.FirstOrDefault(w => w.Identifier == roomId);

            if (room == null)
            {
                return(new NotFoundObjectResult(new { Message = "This session no longer exists" }));
            }

            var story = room.Stories.FirstOrDefault(w => w.Identifier == storyId);

            if (story == null)
            {
                return(new NotFoundObjectResult(new { Message = "Story not found" }));
            }

            story.Title  = storyModel.Title ?? story.Title;
            story.Points = storyModel.Points ?? story.Points;
            story.Status = storyModel.Status ?? story.Status;

            return(new AcceptedResult("", story));
        }
Пример #3
0
        public object AddStory(int roomId, [FromBody] StoryApiModel story)
        {
            if (string.IsNullOrWhiteSpace(story.Title))
            {
                return(new BadRequestObjectResult(new { Message = "Title is not valid" }));
            }

            var room = this.Rooms.FirstOrDefault(w => w.Identifier == roomId);

            if (room == null)
            {
                return(new NotFoundObjectResult(new { Message = "This session no longer exists" }));
            }

            var newStory = new Story()
            {
                Title = story.Title
            };

            room.Stories.Add(newStory);
            return(Created("", newStory));
        }