public static CategoryDTO Map(this Category source) { var target = new CategoryDTO(); target.Id = source.Id; target.Name = source.Name; return target; }
public void TestUserPermissions() { using (Hobby.SimpleInjector.SimpleInjectorConsole.Instance.BeginLifetimeScope()) { var uow = IoCCProvider.Container.GetInstance<IUnitOfWork>(); var categorie = new CategoryDTO { Name = "testCategorie1" }; var permissions = new PermissionDTO { Name = "testPermission1", Deleted = false, Description = "TEST" }; var user = new UserDTO { FirstName = "testlogin1", Password = "******" }; //Trzeba przypsiac do obiektu var entityPer = permissions.Map(); var entityUse = user.Map(); uow.Permissions.Add(entityPer); uow.Users.Add(entityUse); uow.Save(); var userPermission = new UserPermissionDTO() { IdPermission = entityPer.Id, IdUser = entityUse.Id }; uow.UserPermissions.Add(userPermission.Map()); uow.Save(); } }