Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
 public async Task RemoveRosterLocation(LocationJut location)
 {
     await _repository.DeleteLocation(location.JutToLocation());
 }
Esempio n. 5
0
 public async Task <LocationJut> UpdateRosterLocation(LocationJut location)
 {
     return((await _repository.UpdateLocation(location.JutToLocation())).Jut());
 }
Esempio n. 6
0
        public async Task <LocationJut> CreateRosterLocation(LocationJut location)
        {
            Location result = await _repository.CreateLocation(location.JutToLocation());

            return(result.Jut());
        }