Пример #1
0
        public async Task <IActionResult> ChangeLocation([FromHeader(Name = "api_key")] string apiKey, [FromBody] LocationDTO newLocation)
        {
            Worker worker = await workerService.GetByApiKeyAsync(apiKey);

            if (worker == null)
            {
                return(Unauthorized());
            }

            if (newLocation == null || !TryValidateModel(newLocation))
            {
                return(BadRequest(ModelState));
            }

            if (await workerService.ChangeLocationAsync(worker, newLocation))
            {
                return(Ok());
            }

            return(BadRequest());
        }