public void Add(ModelBookStore.UserRole objModelUserRole) { UserRole objUserRole = new UserRole() { UserId = objModelUserRole.UserId, RoleId = objModelUserRole.RoleId }; TBSEntities.UserRoles.Add(objUserRole); TBSEntities.SaveChanges(); }
public void Update(ModelBookStore.UserRole objModelUserRole) { UserRole _SelectUserRole = TBSEntities.UserRoles.Where(x => x.UserId == objModelUserRole.UserId //&& x.RoleId == objModelUserRole.RoleId ).Select(x => x).FirstOrDefault(); if (_SelectUserRole == null) { Add(objModelUserRole); } else { _SelectUserRole.RoleId = objModelUserRole.RoleId; _SelectUserRole.UserId = objModelUserRole.UserId; TBSEntities.SaveChanges(); } }