/// <summary> /// /// </summary> /// <param name="sortOrder"></param> /// <param name="currentFilter"></param> /// <param name="searchString"></param> /// <param name="pageNumber"></param> /// <param name="exhibitionId"></param> /// <returns></returns> public ActionResult AddArtwork(string sortOrder, string currentFilter, string searchString, int?pageNumber, long?exhibitionId) { if (string.IsNullOrEmpty(sortOrder)) { sortOrder = string.Empty; } ViewData["ExhibitionId"] = exhibitionId; ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ArtworkExhibitionCheckModel model = new ArtworkExhibitionCheckModel(); var artworks = _context.Artworks.Include(d => d.Artist).Select(item => new ArtworkModel { ArtistId = item.ArtistId, ArtworkId = item.ArtworkId, Active = item.Active, Name = item.Name, PrefabName = item.PrefabName, DescriptionEn = Helper.Helper.GetStringByLanguage(item.Description, 30), NameEn = Helper.Helper.GetStringByLanguage(item.Name, 0), ArtistNameEn = Helper.Helper.GetStringByLanguage(item.Artist.Name, 0), }).ToList(); if (searchString != null) { pageNumber = 1; } else { searchString = currentFilter; } ViewData["CurrentFilter"] = searchString; if (!String.IsNullOrEmpty(searchString)) { artworks = artworks.Where(p => (p.Name != null && p.Name.ToLower().Contains(searchString.ToLower())) || (p.Description != null && p.Description.ToLower().Contains(searchString.ToLower()))).ToList(); } switch (sortOrder) { case "name_desc": artworks = artworks.OrderByDescending(p => p.Name).ToList(); break; default: artworks = artworks.OrderBy(p => p.Name).ToList(); break; } int pageSize = 10; return(PartialView("_AddArtwork", artworks.ToPagedList(pageNumber ?? 1, pageSize))); }
/// <summary> /// /// </summary> /// <param name="sortOrder"></param> /// <param name="currentFilter"></param> /// <param name="searchString"></param> /// <param name="pageNumber"></param> /// <param name="exhibitionId"></param> /// <returns></returns> public ActionResult SaveArtworks(ArtworkExhibitionCheckModel artworkModels) { return(RedirectToAction("Edit", "ExhibitionController", new { id = 12 })); }