public IActionResult Edit([FromForm] ThoughtEditModel model) { var thought = model.Map <ThoughtModel>(); _thoughtService.Save(thought); return(RedirectToAction("All")); }
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); }
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); }
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); } }