コード例 #1
0
        public IActionResult Edit([FromForm] ThoughtEditModel model)
        {
            var thought = model.Map <ThoughtModel>();

            _thoughtService.Save(thought);
            return(RedirectToAction("All"));
        }
コード例 #2
0
        public void ThoughtService_SaveNewThought_GetAllContainsIt()
        {
            // arrange
            IThoughtService service = GetServiceInstance();
            ThoughtModel    thought = GetRandomThought();

            // act
            service.Save(thought);

            // assert
            Assert.Contains(service.GetAll(), t => t.Id == thought.Id);
        }
コード例 #3
0
        public void ThoughtService_UpdateThought_TitlesAreEquals()
        {
            // arrange
            string          dummyTitle = "I love bananas!";
            IThoughtService service    = GetServiceInstance();
            ThoughtModel    thought    = GetRandomThought();

            // act
            thought       = service.Create(thought);
            thought.Title = dummyTitle;
            thought       = service.Save(thought);

            // assert
            Assert.Equal(dummyTitle, thought.Title);
        }
コード例 #4
0
 public Boolean AddThought([FromBody] AddThoughtViewModel thought)
 {
     try
     {
         var thoughtDto = new ThoughtDto()
         {
             User        = Models.Entities.User.GetDefaultUser(),
             Description = thought.Description,
             Timeframe   = new Timeframe(thought.TimeframeType, thought.DateTime)
         };
         thoughtService.Save(thoughtDto);
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }