public void AddMenu_ValidInput_ExpectTwoItems() { //Act DtoMenu menu1 = new DtoMenu() { TypeEnum = MenuType.Meals, RestaurantName = "Seavus Restaurant" }; DtoMenu menu2 = new DtoMenu() { TypeEnum = MenuType.Drinks, RestaurantName = "Seavus Restaurant" }; //Arrange var menuService = new MenuService(); var result1 = menuService.Add(menu1); var result2 = menuService.Add(menu2); var resultMenus = menuService.LoadAll(); //Assert Assert.IsNotNull(result1); Assert.IsTrue(result1.Success); Assert.IsNotNull(result2); Assert.IsTrue(result2.Success); Assert.IsNotNull(resultMenus); Assert.IsTrue(resultMenus.Success); Assert.IsNotNull(resultMenus.ListItems); Assert.IsTrue(resultMenus.ListItems.Any()); }
public void AddMenu_ValidInput_ExpectTwoItems() { //Act DtoMenu menu1 = new DtoMenu() { TypeEnum = MenuType.Meals, RestaurantName = "Seavus Restaurant" }; DtoMenu menu2 = new DtoMenu() { TypeEnum = MenuType.Drinks, RestaurantName = "Seavus Restaurant" }; //Arrange var menuService = new MenuService(); var result1 = menuService.Add(menu1); // will add them to the database each time the test is run, and the entries are repeated var result2 = menuService.Add(menu2); var resultMenus = menuService.LoadAll(); //Assert Assert.IsNotNull(result1); Assert.IsTrue(result1.Success); Assert.IsNotNull(result2); Assert.IsTrue(result2.Success); Assert.IsNotNull(resultMenus); Assert.IsTrue(resultMenus.Success); Assert.IsNotNull(resultMenus.ListItems); //Assert.AreEqual(2, resultMenus.ListItems.Count); Assert.IsTrue(resultMenus.ListItems.Count >= 2); // since test method adds the same entries to the database, here we check if there are at least 2 created }
public IHttpActionResult BatAdd_Menu(List <sys_menu> entrys) { int items = 0; int okcnt = 0; MenuService svc = new MenuService(); foreach (var entry in entrys) { svc.List(new menuparm { url = entry.path }, out items); if (items == 0) { int cnt = svc.Add(entry); if (cnt > 0) { okcnt++; } } } if (okcnt == entrys.Count()) { return(Json(new { code = 1, msg = "数据保存成功!" })); } else { return(Json(new { code = 0, msg = "数据保存失败!" })); } }
public MainActivity() { this._menuService = new MenuService(); _menuService.Add("DatePicker One", typeof(OneMvvmActivity)) .Add("DatePicker Two", typeof(TwoActivity)) .Add("TimePicker One", typeof(ThreeActivity)); }
public MainActivity() { this._menuService = new MenuService(); _menuService.Add("One sample", typeof(OneActivity)) .Add("Two sample", typeof(TwoActivity)) .Add("Three sample", typeof(ThreeActivity)); }
public void Index() { MenuService service = new MenuService(); List <sys_menu> list = new List <sys_menu>(); list.Add(new sys_menu() { pid = 0, title = "系统管理", icon = "dashboard", code = "systemmgr", menutype = "01", path = "/systemmgr", viewpath = "", seq = 2, adduser = 1 }); list.Add(new sys_menu() { pid = 1, title = "用户管理", icon = "user", code = "usermgr", menutype = "02", path = "usermgr", viewpath = "user/index", seq = 3, adduser = 1 }); list.Add(new sys_menu() { pid = 1, title = "角色管理", icon = "table", code = "rolemgr", menutype = "01", path = "rolemgr", viewpath = "role/index", seq = 4, adduser = 1 }); list.Add(new sys_menu() { pid = 1, title = "菜单管理", icon = "tree", code = "menumgr", menutype = "01", path = "menumgr", viewpath = "menu/index", seq = 5, adduser = 1 }); foreach (var item in list) { var ret = service.Add(item); System.Console.WriteLine(ret.id); } }
public ActionResult Publish(Guid id) { SysSetFormService service = new SysSetFormService(); var model = service.Get(id); model.Status = Cupcake.Core.Domain.PublishStatus.Published; int intRv = service.Modify(model); if (intRv > 0) { MenuService mservice = new MenuService(); Cupcake.Core.Domain.Menu menu = new Cupcake.Core.Domain.Menu(); menu.Name = model.FuntionName; menu.Sort = 9; menu.Href = "/ShowForm?t=" + model.TableName; menu.ParentId = mservice.GetRootId();//new Guid("210D56FF-8EB0-E611-A9D4-00247EDEF854"); menu.CreateDate = DateTime.Now; menu.UpdateDate = DateTime.Now; menu.IsDelete = false; mservice.Add(menu); } return(Json(new { result = "success", msg = "发布成功!" })); }
public ActionResult Add(Menu menu) { if (ModelState.IsValid) { _menuService.Add(menu); return(RedirectToAction("Detail")); } return(View(menu)); }
public ActionResult ComboAdd(Menu menu) { if (ModelState.IsValid) { _menuService.Add(menu); return(Redirect(Url.Action("Home") + "#specialDeals")); } return(View(menu)); }
public ContentResult MenuAdd(Menu model) { HXD.MS.Entity.User user = sessionManager.SessionObject; model.Creater = user.UserName; if (!(menuBll.Add(model) > 0)) { return(Content(AjaxMsgHelper.AjaxMsg(CodeType.Error, "新增失败"))); } return(Content(AjaxMsgHelper.AjaxMsg())); }
public async Task <ResponseDto> AddOrEditMenu(Menu menu) { if (menu.Id > 0) { result.data = await bll.Edit(menu); } else { result.data = await bll.Add(menu); } return(result); }
public ActionResult Add(Menu menu) { if (menuService.Exist(m => m.Name == menu.Name)) { return(Fail("此菜单名已存在")); } menu = menuService.Add(menu); if (menu.Id > 0) { return(Success()); } return(Fail()); }
public IHttpActionResult Add_Menu(sys_menu entry) { try { var route = Request.GetRouteData(); MenuService svc = new MenuService(); int cnt = svc.Add(entry); return(cnt > 0 ? Json(new { code = 1, msg = "ok" }) : Json(new { code = 0, msg = "编码重复!" })); } catch (Exception e) { return(Json(new { code = 0, msg = e.Message })); } }
public MainActivity() { this._menuService = new MenuService(); _menuService.Add("Linear Layout", typeof(LinearLayoutActivity)) .Add("RelativeLayout", typeof(RelativeLayoutActivity)) .Add("Relative Layout One", typeof(RelativeLayoutOneActivity)) .Add("Frame Layout", typeof(FrameLayoutActivity)) .Add("Complex Relative Layout", typeof(ComplexRelativeLayout)) .Add("Custom Layout", typeof(CustomLayoutActivity)) .Add("Table Layout", typeof(TableLayoutActivity)) .Add("Programatically Table Layout", typeof(ProgramaticTableLayoutActivity)) .Add("Dynamic Table Layout", typeof(DynamicTableActivity)) .Add("GrdiView Layout", typeof(GridViewActivity)); }
public ActionResult Create(menu menu) { //ms.Add(menu); //ms.Commit(); //return RedirectToAction("../menu/create"); menu c = new menu { name = menu.name, orderNumber = menu.orderNumber, price = menu.orderNumber, idRestaurant = menu.idRestaurant, }; if (ModelState.IsValid) { ms.Add(c); ms.Commit(); } return(RedirectToAction("Index")); }
public void TestMenu_Add_NotNull() { //Unity.Init(); // IMainDbFactory factory = new CustomDbTestFactory(); var menuService = new MenuService(factory); var mainDBTestTool = new MainDBTestTool(factory); var menu = new Menu(); menu.Url = "///"; menu.Name = "测试"; menuService.Add(menu); mainDBTestTool.Commit(); //_dbTool = MvcBase.Unity.Get<IMainDBTestTool>(); //_menuService.Add(new Menu()); //_dbTool.Commit(); var expect = 55; Assert.True(expect == 55); }
public IHttpActionResult Add(dynamic obj) { try { int pid = 0, status = 1, adduserid = 0, seq; int.TryParse(obj.pid.ToString(), out pid); int.TryParse(obj.status != null? obj.status.ToString():"1", out status); int.TryParse(obj.adduser != null?obj.adduser.ToString():"0", out adduserid); int.TryParse(obj.seq != null?obj.seq.ToString():"0", out seq); MenuService ms = new MenuService(); sys_menu entity = new sys_menu() { pid = pid, code = obj.code.ToString(), icon = obj.icon.ToString(), path = obj.path.ToString(), title = obj.title.ToString(), viewpath = obj.viewpath.ToString(), menutype = obj.menutype.ToString(), status = status, adduser = adduserid, seq = seq, comname = (obj.comname ?? "").ToString(), addtime = DateTime.Now }; entity = ms.Add(entity); if (entity.id > 0) { return(Json(new { code = 1, msg = "菜单添加成功" })); } else { return(Json(new { code = 0, msg = "菜单添加失败" })); } } catch (Exception e) { return(Json(new { code = 0, msg = e.Message })); } }
private void btn_Save_Click(object sender, EventArgs e) { var m = opState == UIStatus.Add ? newMenu : currentMenu; if (string.IsNullOrEmpty(m.FNumber)) { throw new Exception("菜单编码不能为空!"); } else if (string.IsNullOrEmpty(m.FName)) { throw new Exception("菜单名称不能为空!"); } if (opState == UIStatus.Add) { if (menuService.Exists(m.FNumber)) { throw new Exception("编码:[" + m.FNumber + "], 已经存在!"); } menuService.Add(m); newMenu = null; } else if (opState == UIStatus.Edit) { var oldMenu = menuService.Get(m.FItemID); if (oldMenu.FNumber != m.FNumber) { if (menuService.Exists(m.FNumber)) { throw new Exception("编码:[" + newMenu.FNumber + "], 已经存在!"); } } menuService.Update(m); } SetUIStatus(UIStatus.Browse); this.btn_Refresh_Click(null, null); }
protected void btnSubmit_Click(object sender, EventArgs e) { var res = ms.Add(new Model.reception.Menu() { Menu_Title = txtTitle.Text.Trim(), Menu_Href = txtHref.Text.Trim() }); ReturnMsg rm = res > 0 ? new ReturnMsg { Code = StatusCode.Ok, Message = "新增权限成功", Data = null } : new ReturnMsg { Code = StatusCode.Error, Message = "新增权限失败", Data = null }; Session["Msg"] = rm; Response.Redirect("Menus_list.aspx"); }
public IActionResult AddEdit(AddEditModel model) { var isNameExists = _menuService.IsNameExists(model.Id, model.Name); if (isNameExists.Failed) { return(Json(isNameExists)); } var entity = model.MapTo <Menu>(); if (model.Id.IsNullOrWhiteSpace()) { _menuService.Add(entity); } else { _menuService.Update(entity); } return(Json(ServiceResult.IsSuccess("操作成功"))); }
public async Task <JsonResult> MenuAdd(Menu menu) { try { menu.Code = Guid.NewGuid().ToString("N"); menu.CreatedTime = DateTime.Now; menu.Url = menu.Url.ToLower(); menu.EName = menu.EName.ToLower(); _logService.Debug(string.Format("添加菜单参数!menu = 【{0}】", menu.ToJSON())); var ret = await _menuService.Add(menu); if (ret) { RefreshCache(); } return(Json(new { isadd = ret })); } catch (Exception ex) { _logService.Error(string.Format("添加菜单失败!menu = 【{0}】", menu.ToJSON()), ex); return(Json(new { isadd = false })); } }
public async Task <IResultModel <int> > Add(MenuEntity model) { return(await _service.Add(model)); }
public MainActivity() { this._menuService = new MenuService(); _menuService.Add("ExpandableListView sample", typeof(ExpandableListViewActivity)); }
public MainActivity() { this._menuService = new MenuService(); _menuService.Add("Sample One", typeof(OneActivity)) .Add("Sample Two", typeof(TwoActivity)); }
public IActionResult Add(MenuFormParams menuFormParams) { var result = _menuService.Add(menuFormParams.ToDto <MenuFormParams, MenuAddAndEditModel>()); return(Json(result)); }
public MainActivity() { this._menuService = new MenuService(); _menuService.Add("Basic Data", typeof(OneActivity)) .Add("Advanced Data", typeof(TwoActivity)); }
public MainActivity() { this._menuService = new MenuService(); _menuService.Add("Countries AutoComplete", typeof(OneActivity)); }
public MainActivity() { this._menuService = new MenuService(); _menuService.Add("Gallery One", typeof(OneActivity)); }
public IHttpActionResult AddFuns_Filed(dynamic menu) { try { MenuService ms = new MenuService(); List <dynamic> funs = menu.funs.ToObject <List <dynamic> >(); List <dynamic> fiels = menu.fields.ToObject <List <dynamic> >(); funs = funs.Where(t => !string.IsNullOrEmpty((t.name ?? "").ToString()) && !string.IsNullOrEmpty((t.code ?? "").ToString())).ToList(); fiels = fiels.Where(t => !string.IsNullOrEmpty((t.name ?? "").ToString()) && !string.IsNullOrEmpty((t.code ?? "").ToString())).ToList(); int pid = 0, adduserid = 0; List <int> oklist = new List <int>(); int.TryParse(menu.pid != null?menu.pid.ToString():"0", out pid); int.TryParse(menu.adduser != null?menu.adduser.ToString():"0", out adduserid); var codelist = ms.FindCodesByPid(pid); List <sys_menu> insertlist = new List <sys_menu>(); foreach (var item in funs) { var isexsit = codelist.Where(t => t == item.code.ToString()).Count(); if (isexsit > 0) { continue; } var entity = new sys_menu() { code = item.code, menutype = "03", title = item.name, pid = pid, addtime = DateTime.Now, seq = 10, status = 1, icon = "", adduser = adduserid }; insertlist.Add(entity); } foreach (var item in fiels) { var isexsit = codelist.Where(t => t == item.code.ToString()).Count(); if (isexsit > 0) { continue; } var entity = new sys_menu() { code = item.code, menutype = "04", title = item.name, pid = pid, addtime = DateTime.Now, seq = 10, status = 1, icon = " ", adduser = adduserid }; insertlist.Add(entity); } if (ms.Add(insertlist)) { return(Json(new { code = 1, msg = "数据保存成功" })); } else { return(Json(new { code = 0, msg = "数据保存失败" })); } } catch (Exception e) { return(Json(new { code = 0, msg = e.Message })); } }
public MainActivity() { this._menuService = new MenuService(); _menuService.Add("Service stocks samples", typeof(StockActivity)); }