示例#1
0
        public int AddModule(int menuId, ModuleType type, int parentId = 0)
        {
            int newId;

            var module = new Domain.Modules()
            {
                MenuId      = menuId,
                ModuleType  = (int)type,
                Position    = GetNextPosition(menuId, parentId),
                CreatedAt   = DateTime.Now,
                CreatedById = Authentication.Instance.GetUserId()
            };

            if (parentId > 0)
            {
                module.ParentId = parentId;
            }


            using (var session = new DataSession())
            {
                var modulesRepo = new ModulesRepository(session.UnitOfWork);

                newId = modulesRepo.Save(module);
            }
            return(newId);
        }