public UpdateAttempt ResizeGrid(ResizeGridModel model) { var grid = this.GetGrid(); grid.Dimensions = new CoordinateModel { X = model.X, Y = model.Y }; // query: should we be "discovering" ships previously marked as lost? spec says "lost forever" // also: can we abstract this away (creating and updating the grid json string) var gridJson = JsonConvert.SerializeObject(grid); var result = _dataService.UpdateGrid(gridJson); return(result); }
public ActionResult ResizeGrid(ResizeGridModel coords) { if (coords?.X == coords?.Y) { ModelState.AddModelError("", "Grid must be a rectangle"); } if (!ModelState.IsValid) { return(Errors()); } var result = _shipTrackingService.ResizeGrid(coords); if (result.Success) { return(this.RenderGrid()); } ModelState.AddModelError("", result.Message); return(Errors()); }