Esempio n. 1
0
        public IActionResult GetByUserId(int id)
        {
            // only allow admins to access other user records
            var currentUserId = int.Parse(User.Identity.Name);

            if (id != currentUserId && !User.IsInRole(Role.Admin))
            {
                return(Forbid());
            }

            var plan = _planServices.GetPlanByUserId(id);

            if (plan == null)
            {
                return(NotFound());
            }

            return(Ok(plan));
        }