static void Main(string[] args) { ProductDbObject product1 = new ProductDbObject() { Category = new CategoryDbObject() { Name = "Pizza", PrimaryKey = new Guid() }, Name = "JakasTam", PrimaryKey = new Guid() }; CategoryDbObject PizzaCategory = new CategoryDbObject() { Name = "Pizza", PrimaryKey = new Guid() }; CategoryService catgeService = new CategoryService(new HtcEfDbContext()); catgeService.AddEntity(PizzaCategory); catgeService.SaveChange(); }
public IActionResult CategoryAdd(CategoryDto viewModel) { viewModel.wxapp_id = GetAdminSession().wxapp_id; viewModel.create_time = DateTime.Now; viewModel.update_time = DateTime.Now; try { var model = viewModel.Mapper <yoshop_category>(); CategoryService.AddEntity(model); } catch (Exception e) { LogManager.Error(GetType(), e); return(No(e.Message)); } return(YesRedirect("添加成功!", "/goods.category/index")); }