// 删除Category public ActionResult Delete(int id, string CategoryName) { try { CategoryDto dto = new CategoryDto(); DataTable dt = CMSService.SelectOne("Category", "CMSCategory", "CategoryId=" + id); foreach (DataRow dr in dt.Rows) { dto = CategoryMapping.getDTO(dr); } string strwhere = "CategoryParentId=" + id; DataTable categorydt = CMSService.SelectSome("Category", "CMSCategory", strwhere); Message msg = new Message(); if (categorydt.Rows.Count > 0) { msg.MessageInfo = "此角色还有" + categorydt.Rows.Count + "条相关数据,不允许删除"; return(RedirectTo("/Category/Index/" + dto.CategoryParentId + "?CategoryName=" + CategoryName, msg.MessageInfo)); } else { msg = CMSService.Delete("Category", "CMSCategory", "CategoryId=" + id); msg.MessageInfo = "数据删除操作成功"; return(RedirectTo("/Category/Index/" + dto.CategoryParentId + "?CategoryName=" + CategoryName, msg.MessageInfo)); } } catch { return(View()); } }
/// <summary> /// Updates the data. /// </summary> private void UpdateData() { StatusUpdate.StatusMessage = Utilities.GetResourceValue("Loading"); try { if (IsDataValid()) { var categoryMapping = new CategoryMapping { Id = SelectedCategory.Id, EventCategoryId = SelectedCategory.EventCategory, ExceptionType = SelectedCategory.ExceptionType, ModifiedTime = Constants.CurrentTime }; int result = CategoryService.UpdateCategoryMapping(categoryMapping); if (result > 0) { ShowPopup = false; NotificationHelper.ShowMessage(Utilities.GetResourceValue("DataUpdateSuccess"), Utilities.GetResourceValue("CaptionInfo")); BindMappings(); } else { NotificationHelper.ShowMessage(Utilities.GetResourceValue("NothingUpdated"), Utilities.GetResourceValue("CaptionError")); } } } catch (Exception exception) { ShowPopup = false; NotificationHelper.ShowMessage(exception.Message, Utilities.GetResourceValue("CaptionError")); ShowPopup = true; } StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus"); }
public async Task <ActionResult> CategoryList(DataSourceRequest command, CategoryListModel model) { //if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) // return AccessDeniedKendoGridJson(); CategoryViewModel categoryViewModel = new CategoryViewModel(); model.Page = command.Page - 1; model.PageSize = command.PageSize; TEBApiResponse apiResponse = await Post <CategoryListModel>("/Category/CategoryList", model); if (apiResponse.IsSuccess) { List <Category> listCategories = JsonConvert.DeserializeObject <List <Category> >(Convert.ToString(apiResponse.Data)); PagedList <Category> categories = new PagedList <Category>(listCategories, 0, 10); var gridModel = new DataSourceResult(); gridModel.Data = listCategories.Select(x => { var categoryModel = CategoryMapping.ModelToView(x); return(categoryModel); }); gridModel.Total = categories.TotalCount; return(Json(gridModel)); } return(Json(0)); }
public async Task <ActionResult> Create(CategoryViewModel model, string savecontinue) { if (ModelState.IsValid) { bool continueEditing = false; if (!String.IsNullOrWhiteSpace(savecontinue)) { continueEditing = true; } Category objcategory = new Core.Domain.Category(); objcategory = CategoryMapping.ViewToModel(model); TEBApiResponse apiResponse = await Post <Category>("/Category/InsertCategory", objcategory); if (apiResponse.IsSuccess) { if (continueEditing) { //selected tab //SaveSelectedTabName(); int categoryid = JsonConvert.DeserializeObject <int>(Convert.ToString(apiResponse.Data)); return(RedirectToAction("Edit", new { id = categoryid })); } return(RedirectToAction("Category")); } } return(View(model)); }
// Category列表 public ActionResult Index(int?p, int id, string CategoryParentName) { Pager pager = new Pager(); pager.table = "CMSCategory"; pager.strwhere = "CategoryParentId=" + id; pager.PageSize = 10; pager.PageNo = p ?? 1; pager.FieldKey = "CategoryId"; pager.FiledOrder = "CategoryId Desc"; pager = CMSService.SelectAll("Category", pager); List <CategoryDto> list = new List <CategoryDto>(); foreach (DataRow dr in pager.EntityDataTable.Rows) { CategoryDto dto = CategoryMapping.getDTO(dr); list.Add(dto); } pager.Entity = list.AsQueryable(); ViewBag.PageNo = p ?? 1; ViewBag.PageCount = pager.PageCount; ViewBag.RecordCount = pager.Amount; ViewBag.Message = pager.Amount; ViewBag.CategoryParentName = CategoryParentName; ViewBag.CategoryParentId = id; return(View(pager.Entity)); }
public static IMapping CreatMapping(string DtoName) { IMapping Mapping = null; if (DtoName == "User") { Mapping = new UserMapping(); } if (DtoName == "Role") { Mapping = new RoleMapping(); } if (DtoName == "Category") { Mapping = new CategoryMapping(); } if (DtoName == "Article") { Mapping = new ArticleMapping(); } if (DtoName == "Image") { Mapping = new ImageMapping(); } if (DtoName == "Customer") { Mapping = new CustomerMapping(); } if (DtoName == "Tizhi") { Mapping = new TizhiMapping(); } if (DtoName == "Xueya") { Mapping = new XueyaMapping(); } if (DtoName == "Jianyan") { Mapping = new JianyanMapping(); } if (DtoName == "Chufang") { Mapping = new ChufangMapping(); } if (DtoName == "Jixiao") { Mapping = new JixiaoMapping(); } if (DtoName == "Fankui") { Mapping = new FankuiMapping(); } if (DtoName == "Yuyue") { Mapping = new YuyueMapping(); } return(Mapping); }
public static string CategoryIdToName(string strWhere) { CategoryDto dto = new CategoryDto(); DataTable dt = CMSService.SelectOne("Category", "CMSCategory", strWhere); foreach (DataRow dr in dt.Rows) { dto = CategoryMapping.getDTO(dr); } return(dto.CategoryName); }
public async Task <ActionResult> Edit(int id) { CategoryViewModel model = new CategoryViewModel(); TEBApiResponse apiResponse = await Get("/Category/GetCategoryById?Id=" + id); if (apiResponse.IsSuccess) { Category product = JsonConvert.DeserializeObject <Category>(Convert.ToString(apiResponse.Data)); model = CategoryMapping.ModelToView(product); } return(View(model)); }
//分类列表 public static List <CategoryDto> GetCategoryList(string strwhere) { List <CategoryDto> CategoryList = new List <CategoryDto>(); DataTable dt = CMSService.SelectSome("Category", "CMSCategory", strwhere); foreach (DataRow dr in dt.Rows) { CategoryDto dto = CategoryMapping.getDTO(dr); CategoryList.Add(dto); } return(CategoryList); }
//分类的下拉列表显示 public static List <SelectListItem> GetCategorySelectList(string strwhere) { DataTable dt = CMSService.SelectSome("Category", "CMSCategory", strwhere); List <SelectListItem> items = new List <SelectListItem>(); foreach (DataRow dr in dt.Rows) { CategoryDto dto = CategoryMapping.getDTO(dr); items.Add(new SelectListItem { Text = dto.CategoryName, Value = dto.CategoryId.ToString() }); } return(items); }
/// <summary> /// Rows the selected. /// </summary> /// <param name="selectedRow">The selected row.</param> private void RowSelected(object selectedRow) { CategoryMapping selectedCategoryRow = selectedRow as CategoryMapping; if (selectedCategoryRow == null) { return; } SelectedCategory = new CategoryMappingModel { EventCategory = selectedCategoryRow.EventCategoryId, ExceptionType = selectedCategoryRow.ExceptionType, Id = selectedCategoryRow.Id }; ShowPopup = true; }
// 编辑Category视图 public ActionResult Edit(int id, string CategoryParentName) { CategoryModel model = new CategoryModel(); DataTable dt = CMSService.SelectOne("Category", "CMSCategory", "CategoryId=" + id); foreach (DataRow dr in dt.Rows) { CategoryDto dto = new CategoryDto(); dto = CategoryMapping.getDTO(dr); model.CategoryId = dto.CategoryId; model.CategoryName = dto.CategoryName; model.CategoryDescription = dto.CategoryDescription; model.CategoryParentId = dto.CategoryParentId; model.CategoryParentName = CategoryParentName; } return(View(model)); }
protected override Dictionary <Product, IEnumerable <string> > GetValues(List <Product> objs) { var allCategories = _session.QueryOver <Category>().Cacheable().List().ToDictionary(x => x.Id); Category categoryAlias = null; CategoryMapping mapping = null; var mappings = _session.QueryOver <Product>() .JoinAlias(x => x.Categories, () => categoryAlias) .SelectList(builder => { builder.Select(x => x.Id).WithAlias(() => mapping.ProductId); builder.Select(() => categoryAlias.Id).WithAlias(() => mapping.CategoryId); return(builder); }).TransformUsing(Transformers.AliasToBean <CategoryMapping>()).List <CategoryMapping>() .GroupBy(x => x.ProductId, x => x.CategoryId) .ToDictionary(x => x.Key); return(objs.ToDictionary(product => product, product => GetCategories(mappings.ContainsKey(product.Id) ? mappings[product.Id] : Enumerable.Empty <int>(), allCategories))); }
public static double GetFenshuByCategory(int categoryId) { double fenshu = 0; CategoryDto dto = new CategoryDto(); DataTable dt = CMSService.SelectOne("Category", "CMSCategory", "CategoryId=" + categoryId); foreach (DataRow dr in dt.Rows) { dto = CategoryMapping.getDTO(dr); } try { fenshu = double.Parse(dto.CategoryDescription); } catch { fenshu = 0; } return(fenshu); }
public ActionResult Edit(CategoryModel model) { CategoryDto dto = new CategoryDto(); DataTable dt = CMSService.SelectOne("Category", "CMSCategory", "CategoryId=" + model.CategoryId); foreach (DataRow dr in dt.Rows) { dto = CategoryMapping.getDTO(dr); dto.CategoryId = model.CategoryId; dto.CategoryName = model.CategoryName; dto.CategoryDescription = model.CategoryDescription; dto.CategoryParentId = model.CategoryParentId; } string JsonString = JsonHelper.JsonSerializerBySingleData(dto); Message msg = CMSService.Update("Category", JsonString); // TODO: Add update logic here return(RedirectTo("/Category/Index/" + model.CategoryParentId + "?CategoryParentName=" + model.CategoryParentName, msg.MessageInfo)); }
public ActionResult Create(ImageModel model) { ImageDto dto = new ImageDto(); dto.ImageTitle = model.ImageTitle; if (String.IsNullOrEmpty(model.ImageUrl)) { ViewBag.status = "Error"; ViewBag.msg = "图片不能为空"; DataTable dt = CMSService.SelectSome("Category", "CMSCategory", "CategoryParentId=6"); List <SelectListItem> items = new List <SelectListItem>(); //List<CategoryDto> list = new List<CategoryDto>(); foreach (DataRow dr in dt.Rows) { CategoryDto categoryDto = CategoryMapping.getDTO(dr); items.Add(new SelectListItem { Text = categoryDto.CategoryName, Value = categoryDto.CategoryId.ToString() }); // list.Add(dto); } ViewData["Category"] = items; return(View()); } else { dto.ImageUrl = model.ImageUrl; } dto.ImageHref = model.ImageHref; dto.ImageDescription = model.ImageDescription; dto.ImageCategory = model.ImageCategory; dto.ImageStatus = false; string JsonString = JsonHelper.JsonSerializerBySingleData(dto); Message msg = CMSService.Insert("Image", JsonString); return(RedirectTo("/Image/Index", msg.MessageInfo)); }
public static async Task TasksOnStartUp(IConfiguration configuration, IMemoryCache memoryCache) { var categoryMapping = new CategoryMapping(new CategoryRepository(configuration, memoryCache), new CategoryRelRepository(configuration, memoryCache)); await categoryMapping.PopulateAllCategories(); var movieRepo = new MovieRepository(configuration, memoryCache); var movies = await movieRepo.GetAllMovies(); if (!configuration.GetConnectionString("DefaultConnection").Contains("test")) { await MovieGenrePopulating.PopulateTmdbMovieGenres(new MovieGenreRepository(configuration, memoryCache)); await TVShowGenrePopulating.PopulateTmdbTVShowGenres(new TVShowGenreRepository(configuration, memoryCache)); await new MoviePopulating(configuration, memoryCache).PopulateManyMovies(); await new TVShowPopulating(configuration, memoryCache).PopulateManyTVShowsTask(); // await new MediaListPopulating(configuration, memoryCache).CreateImdbMovieList("ls051203792", // "\"The Great Movies\" by Roger Ebert"); // await new MediaListPopulating(configuration, memoryCache).CreateImdbMovieList("ls055315312", // "Top 95 Spy/Thriller Movies"); // // await new MediaListPopulating(configuration, memoryCache).CreateImdbTVShowList("ls004499891", // "Best Of The Best TV Shows of 2000-2017"); // // await new MediaListPopulating(configuration, memoryCache).CreateImdbTVShowList("ls059270048", // "TV Series I Would Watch Again (2000-2014)"); // // await new MediaListPopulating(configuration, memoryCache).CreateImdbTVShowList("ls051600015", // "250: Top TV Series, HBO, Showtime:"); } }
public CategoryMapping Update(CategoryMapping entity) { return(_categoryMappingDal.Update(entity)); }
public CategoryMapping Delete(CategoryMapping entity) { return(_categoryMappingDal.Delete(entity)); }
public CategoryMapping Add(CategoryMapping entity) { return(_categoryMappingDal.Add(entity)); }
public static IServiceCollection AddMongoMappers(this IServiceCollection services) { ProductMapping.Mapper(); CategoryMapping.Mapper(); return(services); }
/// <summary> /// Cet DEXI Category /// </summary> /// <param name="cat">Category</param> /// <returns>Output Value</returns> public int?GetCategoryMapping(string cat) { return(CategoryMapping.FirstOrDefault(e => e.Name == cat)?.Value);// g[value]; }
public ActionResult MapCategory(int CategoryID, int Id, int CategoryMapID) { bool status = false; string message = ""; if (Request.Form.Count > 0) { var categoryAmazon = _categoryAmazonRepo.GetById(Id); var category = _categoryRepo.GetById(CategoryID); if (CategoryMapID == 0) { if (CategoryID != 0) { var entity = new CategoryMapping { CategoryId = CategoryID, CategorySourceId = Id, SourceId = 2 }; _categoryMapRepo.Insert(entity); } var result = new CategoryAmazonModel { BrowseNodeID = categoryAmazon.BrowseNodeID, CategoryID = 0, Id = categoryAmazon.Id, CategoryMapID = 0, Name = categoryAmazon.Name, ParentBrowseNodeID = categoryAmazon.ParentBrowseNodeID, }; return(Json(result)); } else { var entity = _categoryMapRepo.GetById(CategoryMapID); if (entity != null) { if (CategoryID != 0) { entity.CategoryId = CategoryID; _categoryMapRepo.Update(entity); var result = new CategoryAmazonModel { BrowseNodeID = categoryAmazon.BrowseNodeID, CategoryID = category.Id, Id = categoryAmazon.Id, CategoryMapID = entity.Id, Name = categoryAmazon.Name, ParentBrowseNodeID = categoryAmazon.ParentBrowseNodeID, }; return(Json(result)); } else { _categoryMapRepo.Delete(entity); var result = new CategoryAmazonModel { BrowseNodeID = categoryAmazon.BrowseNodeID, CategoryID = 0, Id = categoryAmazon.Id, CategoryMapID = 0, Name = categoryAmazon.Name, ParentBrowseNodeID = categoryAmazon.ParentBrowseNodeID, }; return(Json(result)); } } } } return(Json(new { Status = status, Message = message })); }
/// <summary> /// There are no comments for CategoryMappingSet in the schema. /// </summary> public void AddToCategoryMappingSet(CategoryMapping categoryMapping) { base.AddObject("CategoryMappingSet", categoryMapping); }
/// <summary> /// Create a new CategoryMapping object. /// </summary> /// <param name="categoryID">Initial value of CategoryID.</param> /// <param name="referenceCategoryID">Initial value of ReferenceCategoryID.</param> /// <param name="program">Initial value of Program.</param> public static CategoryMapping CreateCategoryMapping(int categoryID, int referenceCategoryID, string program) { CategoryMapping categoryMapping = new CategoryMapping(); categoryMapping.CategoryID = categoryID; categoryMapping.ReferenceCategoryID = referenceCategoryID; categoryMapping.Program = program; return categoryMapping; }