コード例 #1
0
ファイル: WidgetController.cs プロジェクト: ingvaar/Area-back
        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());
        }
コード例 #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)));
        }
コード例 #3
0
ファイル: UserController.cs プロジェクト: ingvaar/Area-back
        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()
            });
コード例 #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));
        }