Ejemplo n.º 1
0
        public async Task <ActionResult <Response> > AddProject([FromBody] AddProjectViewModel accountViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(Ok(new Response {
                    Successful = "true", Msg = ModelState.Values.ToString(), Data = null
                }));
            }

            try
            {
                var userId = HttpContext.User.Claims.First(c => c.Type == "uid").Value.ToString();
                var role   = await AzureService.FindUserRole(userId);

                //if (role != "admin")
                //{
                //    return StatusCode(403);
                //}
                string projectId = await AzureService.AddProject(accountViewModel);

                await AzureService.AddProjectManagerByUserId(projectId, userId);

                return(Ok(new Response {
                    Msg = "ok"
                }));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }