public IHttpActionResult Post(DashboardModel dashboardModel) { if (ModelState.IsValid) { var dashboard = new Dashboard { Title = dashboardModel.Title, Config = dashboardModel.Config, Id = Guid.NewGuid().ToString("n"), Description = dashboardModel.Description, DataSource = dashboardModel.DataSource }; try { dashboard.UserId = (dashboardModel.UserName == null) ? GetCurrentUserId() : GetIdByUsername(dashboardModel.UserName); _dashboardService.Add(dashboard); return Ok(new { Message = (string)null }); } catch (Exception e) { return Ok(new { Message = e.Message }); } } return BadRequest(); }
public IHttpActionResult Put(string id, DashboardModel dashboard) { if (ModelState.IsValid) { var currDashboard = _dashboardService.GetById(id); currDashboard.Config = dashboard.Config; currDashboard.DataSource = dashboard.DataSource; currDashboard.Title = dashboard.Title; currDashboard.Description = dashboard.Description; _dashboardService.Update(currDashboard); return Ok(); } return BadRequest(); }