コード例 #1
0
        public ActionResult <StoryCreationViewModel> Post([FromBody] UpdateStoryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var ownerId      = HttpContext.User.Identity.Name;
            var creationTime = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds();
            var storyId      = Guid.NewGuid().ToString();
            var story        = new Story {
                Id           = storyId,
                Title        = model.Title,
                Content      = model.Content,
                Tags         = model.Tags,
                CreationTime = creationTime,
                LastEditTime = creationTime,
                OwnerId      = ownerId,
                Draft        = true
            };

            storyRepository.Add(story);
            storyRepository.Commit();

            return(new StoryCreationViewModel {
                StoryId = storyId
            });
        }
コード例 #2
0
 public void Commit()
 {
     _innerRepository.Commit();
 }