Exemple #1
0
 public void Create(UserRoleRepository userRoleRepository)
 {
     Models.UserRole newUserRole = new Models.UserRole();
     newUserRole.Userid = userRoleRepository.Userid;
     newUserRole.Roleid = userRoleRepository.Roleid;
     this.save(newUserRole);
 }
Exemple #2
0
 private void save(Models.UserRole UserRole, bool isUpdate = false)
 {
     if (!isUpdate)
     {
         this.context.UserRoles.Add(UserRole);
     }
     this.context.SaveChanges();
 }
Exemple #3
0
        public void Update(long id, UserRoleRepository userRoleRepository)
        {
            Models.UserRole oldUserRole = this.userRoleQueryRepository.Find(id);
            if (oldUserRole == null)
            {
                return;
            }

            oldUserRole.Userid = userRoleRepository.Userid;
            oldUserRole.Roleid = userRoleRepository.Roleid;
            this.save(oldUserRole, true);
        }
Exemple #4
0
        public UserRoleRepository FindByUserAndRole(long userid, long roleid)
        {
            Models.UserRole userRole = this.context.UserRoles.Where(userRole => userRole.Userid == userid && userRole.Roleid == roleid).FirstOrDefault();
            if (userRole == null)
            {
                return(new UserRoleRepository());
            }

            this.userRoleRepository.Id     = userRole.Id;
            this.userRoleRepository.Userid = userRole.Userid;
            this.userRoleRepository.Roleid = userRole.Roleid;
            this.userRoleRepository.MapToRoleRepo(userRole.Role);
            this.userRoleRepository.MapToUserRepo(userRole.User);

            return(this.userRoleRepository);
        }
Exemple #5
0
        public UserRoleRepository FindById(long id = 0)
        {
            Models.UserRole userRole = this.Find(id);
            if (userRole == null)
            {
                return(new UserRoleRepository());
            }

            this.userRoleRepository.Id     = userRole.Id;
            this.userRoleRepository.Userid = userRole.Userid;
            this.userRoleRepository.Roleid = userRole.Roleid;
            this.userRoleRepository.MapToRoleRepo(userRole.Role);
            this.userRoleRepository.MapToUserRepo(userRole.User);

            return(this.userRoleRepository);
        }
Exemple #6
0
 public void Delete(long id)
 {
     Models.UserRole userRole = this.context.UserRoles.Where(userRole => userRole.Id == id).FirstOrDefault();
     this.context.UserRoles.Remove(userRole);
     this.context.SaveChanges();
 }