Example #1
0
        public static int Add(Esmart_Sys_Navigations model)
        {
            var engine = PermissionDb.CreateEngine();
            int max;

            try
            {
                max = engine.Esmart_Sys_Navigations.Max(a => a.NavigationId);
            }
            catch
            {
                max = 0;
            }
            model.NavigationId = max + 1;

            model.CreateTime = DateTime.Now;

            engine.Esmart_Sys_Navigations.Add(model);

            int code = engine.SaveChanges();

            if (code <= 0)
            {
                throw new TpoBaseException("新增异常");
            }
            RightLogDb.AddLog(new Esmart_Right_Log {
                CreateBy = model.CreateId, CreateTime = System.DateTime.Now, EventType = "add", OprTbName = "Esmart_Sys_Navigations", OprUserId = model.CreateId, OptDescription = string.Format(logFormat, model.CreateId, "添加", model.NavigationId), Remark = JsonConvert.SerializeObject(model)
            });
            CommonAction.ClearCache();

            return(model.NavigationId);
        }
Example #2
0
        /// <summary>
        /// 添加一个菜单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(MeunModel model)
        {
            Esmart_Sys_Navigations DbModel = new Esmart_Sys_Navigations()
            {
                AppId = model.AppId, CreateId = model.CreateId, CreateTime = model.CreateTime, Iconurl = model.Iconurl, InClassName = model.InClassName, NavigationId = model.Id, OutClassName = model.OutClassName, ParentID = model.ParentID, SortNo = model.SortNo, Title = model.Title, Url = model.Url
            };

            int code = Data.MenuManager.Add(DbModel);

            return(code);
        }
Example #3
0
        public static int Delete(Esmart_Sys_Navigations model)
        {
            var engine = PermissionDb.CreateEngine();

            engine.Esmart_Sys_Navigations.Remove(model);

            int reInt = engine.SaveChanges();

            RightLogDb.AddLog(new Esmart_Right_Log {
                CreateBy = model.CreateId, CreateTime = System.DateTime.Now, EventType = "delete", OprTbName = "Esmart_Sys_Navigations", OprUserId = model.CreateId, OptDescription = string.Format(logFormat, model.CreateId, "删除", model.NavigationId), Remark = JsonConvert.SerializeObject(model)
            });
            CommonAction.ClearCache();

            return(reInt);
        }
Example #4
0
        public static int Update(Esmart_Sys_Navigations model)
        {
            var engine = PermissionDb.CreateEngine();

            engine.Esmart_Sys_Navigations.Attach(model);

            engine.Entry(model).State = EntityState.Modified;

            var code = engine.SaveChanges();

            RightLogDb.AddLog(new Esmart_Right_Log {
                CreateBy = model.CreateId, CreateTime = System.DateTime.Now, EventType = "update", OprTbName = "Esmart_Sys_Navigations", OprUserId = model.CreateId, OptDescription = string.Format(logFormat, model.CreateId, "修改", model.NavigationId), Remark = JsonConvert.SerializeObject(model)
            });
            CommonAction.ClearCache();

            return(code);
        }
Example #5
0
        public int Update(MeunModel model)
        {
            Esmart_Sys_Navigations dbModel = new Esmart_Sys_Navigations()
            {
                AppId = model.AppId, Iconurl = model.Iconurl, InClassName = model.InClassName, NavigationId = model.Id, OutClassName = model.OutClassName, ParentID = model.ParentID, SortNo = model.SortNo, Title = model.Title, Url = model.Url
            };

            var updateModel = Data.MenuManager.GetModel(model.Id);

            if (updateModel == null)
            {
                throw new TpoBaseException("this  data  is  not existes");
            }
            dbModel.CreateId   = updateModel.CreateId;
            dbModel.CreateTime = updateModel.CreateTime;

            int code = Data.MenuManager.Update(dbModel);

            LogManagerDb.Log(model.CreateId, model.CreateTime, "用户" + model.CreateId + "修改了菜单,菜单名字是:" + model.Title, "menuupdate");

            return(code);
        }