public IHttpActionResult Delete(int id) { widgetManager = new WidgetManager(); if (widgetManager.GetWidget(id) == null) { return(NotFound()); } widgetManager.RemoveWidget(id); return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutName(int id, string title) { widgetManager = new WidgetManager(); if (widgetManager.GetWidget(id) == null) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } widgetManager.ChangeWidgetTitle(id, title); return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult UpdateWidget([FromBody] UserWidgetDTO[] widgets) { widgetManager = new WidgetManager(); foreach (UserWidgetDTO widget in widgets) { if (widget == null) { return(BadRequest("No widget given")); } if (widgetManager.GetWidget(widget.WidgetId) == null) { return(NotFound()); } widgetManager.ChangeWidgetDetails(widget.WidgetId, widget.RowNumber, widget.ColumnNumber, widget.ItemIds.ToList(), widget.RowSpan, widget.ColumnSpan, widget.GraphType); } return(StatusCode(HttpStatusCode.NoContent)); }