public ActionResult ResourceItems(Guid?editItemID) { Guid ID = Guid.NewGuid(); var model = new ResourceListViewModel(); model.CountryAvailability = GlobalSettings.Markets.AvailableMarkets; model.Languages = ExigoDAL.GetUniqueLanguages().ToList(); model.ResourceTypes = ExigoDAL.GetResourceTypes(new GetResourceTypeRequest()); model.Statuses = ExigoDAL.GetResourceStatuses(); model.ResourceCategories = ExigoDAL.GetResourceCategories(new GetResourceCategoriesRequest()); model.Tags = ExigoDAL.GetTagsForResources(new GetTagsForResourcesRequest()); model.IsEdit = false; model.CurrentTags = new List <string>(); if (editItemID != null && editItemID != Guid.Empty) { ID = editItemID ?? ID; model.Resource = ExigoDAL.GetResourceItems(new GetResourcesRequest() { ItemID = ID }).FirstOrDefault(); var TagIDs = ExigoDAL.GetResourceItemTags(new GetResourceItemTagsRequest() { ItemID = ID }).Select(t => t.TagID); model.CurrentTags = model.Tags.Where(t => TagIDs.Contains(t.TagID)).Select(t => t.Name).Distinct().ToList(); model.Resource.ResourceCategoryItems = ExigoDAL.GetResourceCategoryItems(new GetResourceCategoryItemsRequest() { ItemID = ID }); model.Resource.ResourceAvailabilities = ExigoDAL.GetResourceAvailabilities(new GetResourceAvailabilitiesRequest() { ItemID = ID }); //SET Default Values for DropDownList on View model.TypeID = model.Resource.TypeID; model.StatusID = model.Resource.StatusID; model.Language = model.Resource.Language; model.IsEdit = true; } model.EditItemID = editItemID ?? Guid.Empty; return(View(model)); }