Exemplo n.º 1
0
        public ActionResult <IEnumerable <string> > GetWidgetConf([FromQuery] int offset, [FromQuery] int limit, uint id)
        {
            var currentUser = _userBusiness.GetCurrentUser(User);

            if (currentUser != null)
            {
                return(Ok(_widgetBusiness.GetWidgetConf(id, currentUser, offset, limit)));
            }

            return(Unauthorized());
        }
Exemplo n.º 2
0
        public ActionResult <IEnumerable <string> > Get([FromQuery] int offset,
                                                        [FromQuery] int limit)
        {
            var currentUser = _userBusiness.GetCurrentUser(User);

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

            return(Ok(_widgetConfBusiness.GetWidgetConfsByUserId(currentUser.Id, offset, limit)));
        }
Exemplo n.º 3
0
        public IActionResult Put(int id, [FromForm] UserUpdateModel newUser)
        {
            if (!ModelState.IsValid || id < 0)
            {
                return(BadRequest());
            }

            var currentUser = _business.GetCurrentUser(User);

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

            if (currentUser.Id != id)
            {
                return(Unauthorized());
            }

            var success = _business.UpdateUserById(id, newUser, currentUser.Id);

            return(success switch
            {
                1 => (IActionResult)Ok(),
                2 => NotFound(),
                _ => BadRequest()
            });
Exemplo n.º 4
0
        public ActionResult <IEnumerable <string> > Worker(int id)
        {
            var currentUser = _userBusiness.GetCurrentUser(User);

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

            var data = _workerBusiness.GetData(id, currentUser);

            return(data == null ? (ActionResult <IEnumerable <string> >)BadRequest("{\"error\": \"configuration ill-formed\"}") : Ok(data));
        }