public void Create(UserRoleRepository userRoleRepository) { Models.UserRole newUserRole = new Models.UserRole(); newUserRole.Userid = userRoleRepository.Userid; newUserRole.Roleid = userRoleRepository.Roleid; this.save(newUserRole); }
private void save(Models.UserRole UserRole, bool isUpdate = false) { if (!isUpdate) { this.context.UserRoles.Add(UserRole); } this.context.SaveChanges(); }
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); }
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); }
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); }
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(); }