Ejemplo n.º 1
0
        public ActionResult Edit(string id, string ParentId)
        {
            ViewBag.ParentName = _dba.ExecuteScalar <string>("SELECT Name FROM Sec_Menu WHERE MenuId=#MenuId#",
                                                             new { MenuId = ParentId });

            SecMenu model = new SecMenu();

            model.ParentId = ParentId;
            if (id != null)
            {
                model = _menuService.Get(id);
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public JsonResult Save(SecMenu model)
        {
            MyJsonResult mjr = new MyJsonResult();

            using (var dba = DbAccessor.Create())
            {
                try
                {
                    dba.BeginTran();

                    model.ModifiedById = SecurityContext.Current.User.UserId;
                    model.ModifiedDate = DateTime.Now;

                    if (model.MenuId == null)
                    {
                        model.MenuId      = Guid.NewGuid().ToString();
                        model.Status      = (int)StatusType.Enabled;
                        model.CreatedById = SecurityContext.Current.User.UserId;
                        model.CreatedDate = DateTime.Now;
                        dba.ExecuteNonQuery("Security.Menu.Insert", model);
                    }
                    else
                    {
                        dba.UpdateFields(model, "Name", "Url", "IsExpand",
                                         "MobilePhone",
                                         "ModifiedById", "ModifiedDate");
                    }

                    dba.CommitTran();
                    mjr.Success = true;
                    mjr.Message = "保存成功!";
                }
                catch (Exception ex)
                {
                    dba.RollbackTran();
                    mjr.Success = false;
                    mjr.Message = ex.Message;
                }
            }

            return(Json(mjr));
        }