public CommandRepositoryDTO() { commandRepository = new CommandRepository(); var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <Command, CommandDTO>(); cfg.CreateMap <CommandDTO, Command>(); }); mapper = configuration.CreateMapper(); }
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()); }