public ActionResult <DashboardDetails> DashboardsIdGet([FromRoute][Required] string id) { var dashboard = _dashboardService.GetById(id); if (dashboard == null) { return(NotFound()); } var details = new DashboardDetails { Id = dashboard.Id, Name = dashboard.Name, Team = dashboard.Team, LastModified = dashboard.LastModified, Content = dashboard.Content.ToString() }; return(details); }
public IActionResult Put([FromRoute][Required] string id, [FromBody] DashboardInput input) { var dashboard = new DashboardBuilder() .WithId(id) .WithName(input.Name) .WithTeam(input.Team) .WithContent(input.Content) .Build(); _dashboardService.Save(dashboard); var details = new DashboardDetails(); details.Id = dashboard.Id; details.Name = dashboard.Name; details.Team = dashboard.Team; details.LastModified = dashboard.LastModified; details.Content = dashboard.Content.ToString(); return(CreatedAtRoute(GetByIdRouteName, new { id = dashboard.Id }, details)); }
public IActionResult Post([FromBody] DashboardInput input) { var id = IdGenerator.Generate(input.Name + input.Team); var dashboard = new DashboardBuilder() .WithId(id) .WithName(input.Name) .WithTeam(input.Team) .WithContent(input.Content) .Build(); _dashboardService.Save(dashboard); var details = new DashboardDetails { Id = dashboard.Id, Name = dashboard.Name, Team = dashboard.Team, LastModified = dashboard.LastModified, Content = dashboard.Content.ToString() }; return(CreatedAtRoute(GetByIdRouteName, new { id = dashboard.Id }, details)); }