Beispiel #1
0
        public async Task <IActionResult> AddProjectLocation([FromBody] ProjectLocationModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            string userIdVal = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            int    userId    = 0;

            if (!string.IsNullOrEmpty(userIdVal))
            {
                userId = Convert.ToInt32(userIdVal);
            }
            if (userId == 0)
            {
                return(BadRequest("Unauthorized user access to api"));
            }
            var response = await projectService.AddProjectLocation(model, userId);

            if (!response.Success)
            {
                return(BadRequest(response.Message));
            }
            return(Ok(true));
        }