Example #1
0
        public TabRepositoryDTO()
        {
            tabRepository = new TabRepository();
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Tab, TabDTO>();
                cfg.CreateMap <TabDTO, Tab>();
            });

            mapper = config.CreateMapper();
        }
Example #2
0
        public Role AddOrUpdate(Role role)
        {
            bool needAddAtribute = role.Id == 0;

            context.Roles.AddOrUpdate(role);
            context.SaveChanges();
            if (needAddAtribute)
            {
                var roleId   = context.Roles.Where(r => r.Name == role.Name).FirstOrDefault().Id;
                var tabs     = new TabRepository();
                var commands = new CommandRepository();
                tabs.AddTabsForCurrentRole(roleId);
                commands.AddCommandForCurrentRole(roleId);
            }
            return(context.Roles.Where(r => r.Name == role.Name).FirstOrDefault());
        }