public void ReorderGlobal(ReorderSheet data)
        {
            var sheet = context.QuestionSheets
                        .SingleOrDefault(x => x.Id == data.SheetId && x.IsGlobal == true);

            if (sheet == null)
            {
                throw new ServiceException("Parent Sheet Not Found!");
            }

            this.ReorderSheets(data.SheetId, data.Orderings);
        }
 public IActionResult ReorderGlobal([FromBody] ReorderSheet data)
 {
     try
     {
         questionSheetService.ReorderGlobal(data);
         return(Ok());
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 public IActionResult ReorderPersonal([FromBody] ReorderSheet data)
 {
     try
     {
         var userData = jwtService.ParseData(this.User);
         questionSheetService.ReorderPesonal(data, userData.UserId);
         return(Ok());
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public void ReorderPesonal(ReorderSheet data, int userId)
        {
            var user = context.Users.SingleOrDefault(x => x.Id == userId);

            if (user == null)
            {
                throw new ServiceException("User not found!");
            }

            var parentSheet = context.QuestionSheets
                              .SingleOrDefault(x => x.Id == data.SheetId && x.IsGlobal == false);

            if (parentSheet == null)
            {
                throw new ServiceException("Sheet Parent Sheet Not Found!");
            }

            if (parentSheet.UserId != user.Id)
            {
                throw new ServiceException("Sheet does not belong to you!");
            }

            this.ReorderSheets(data.SheetId, data.Orderings);
        }