示例#1
0
        public async Task <IActionResult> ChangeOrder(int userId, int photoId, byte order)
        {
            // Users can change their own data and admins can change any user's data
            if (userId != User.Id && User.Role != Role.Admin)
            {
                return(Unauthorized(new { message = "Unauthorized" }));
            }

            await _photoService.ChangeOrder(userId, photoId, order);

            return(Ok("Changed photo order successfully"));
        }
        public JsonResult ChangeOrder(PhotoSortModel model)
        {
            try
            {
                _photoService.ChangeOrder(model);

                return(Json(MyAjaxHelper.GetSuccessResponse()));
            }
            catch (Exception exception)
            {
                Log.RegisterError(exception);
                return(Json(MyAjaxHelper.GetErrorResponse(exception.Message)));
            }
        }