/// <summary> /// Sort images by group images sort model /// </summary> /// <param name="model"></param> /// <returns></returns> 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 = T("RotatingImage_Message_SortImageSuccessfully") }); } return(new ResponseModel { Success = false, Message = T("RotatingImageGroup_Message_ObjectNotFound") }); }
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.") }); }
public JsonResult SortRotatingImages(GroupImageSortingModel model) { return(Json(_rotatingImageGroupService.SortImages(model))); }