public IActionResult Create([FromBody] TypeCar TypeCar)
        {
            var claims = User.Claims.Select(claim => new { claim.Type, claim.Value }).ToDictionary(t => t.Type, t => t.Value);

            if (claims.ContainsKey("name"))
            {
                if (claims["name"].Equals("ADMIN") || claims["name"].Equals("MANAGER"))
                {
                    TypeCar.Id       = Guid.NewGuid() + "";
                    TypeCar.IsDelete = false;
                    return(Ok(_repository.Create(TypeCar)));
                }
            }
            else
            {
                return(Forbid());
            }
            return(Forbid());
        }
Пример #2
0
 public IActionResult Create([FromBody] TypeCar TypeCar)
 {
     TypeCar.Id       = Guid.NewGuid() + "";
     TypeCar.IsDelete = false;
     return(Ok(_repository.Create(TypeCar)));
 }