public JsonResult SortRotatingImages(GroupImageSortingModel model)
 {
     return Json(_rotatingImageGroupServices.SortImages(model));
 }
Ejemplo n.º 2
0
 public ResponseModel SortImages(GroupImageSortingModel model)
 {
     var group = GetById(model.GroupId);
     if(group != null)
     {
         var images = group.RotatingImages.OrderBy(i => model.Ids.ToList().IndexOf(i.Id)).ToList();
         var dictionary = images.OrderBy(i => i.RecordOrder).Select(i => new {i.Id, i.RecordOrder}).ToList();
         var index = 0;
         foreach (var image in images)
         {
             if (image.Id != dictionary[index].Id)
             {
                 image.RecordOrder = dictionary[index].RecordOrder;
                 _rotatingImageRepository.Update(image);
             }
             index++;
         }
         return new ResponseModel
             {
                 Success = true,
                 Message = _localizedResourceServices.T("AdminModule:::RotatingImagesGroups:::Messages:::SortSuccessfully:::Sort successfully.")
             };
     }
     return new ResponseModel
     {
         Success = false,
         Message = _localizedResourceServices.T("AdminModule:::RotatingImageGroups:::Messages:::ObjectNotFounded:::Rotating image group is not founded.")
     };
 }