public async Task <IActionResult> DeleteLocation([FromRoute] int locationId, [FromBody] LocationJut location) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (locationId != location.LocationId) { return(BadRequest()); } await _service.RemoveRosterLocation(location); return(Ok(location)); }
public async Task <IActionResult> PostLocation([FromBody] LocationJut location) { if (!ModelState.IsValid) { return(StatusCode(StatusCodes.Status400BadRequest, ModelState)); } else if (!(ValidName(location.City) && ValidName(location.State))) { return(StatusCode(StatusCodes.Status400BadRequest, "Missing city and/or state")); } try { await _service.CreateRosterLocation(location); } catch (Exception e) { return(StatusCode(StatusCodes.Status400BadRequest, e)); } return(StatusCode(StatusCodes.Status201Created, location)); }
public async Task <IActionResult> PutLocation([FromRoute] int locationId, [FromBody] LocationJut location) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (locationId != location.LocationId) { return(BadRequest()); } try { location = await _service.UpdateRosterLocation(location); } catch (DbUpdateConcurrencyException) { return(BadRequest("Database Error")); } return(Ok(location)); }
public async Task RemoveRosterLocation(LocationJut location) { await _repository.DeleteLocation(location.JutToLocation()); }
public async Task <LocationJut> UpdateRosterLocation(LocationJut location) { return((await _repository.UpdateLocation(location.JutToLocation())).Jut()); }
public async Task <LocationJut> CreateRosterLocation(LocationJut location) { Location result = await _repository.CreateLocation(location.JutToLocation()); return(result.Jut()); }